Question: I have the following: `param="/var/tmp/test"`
I need to replace the word `test` with another word such as `new_test`

need a smart way to replace the last word after "/" with sed

Answer: 
```
echo 'param="/var/tmp/test"' | sed 's/\/[^\/]*"/\/REPLACEMENT"/'
param="/var/tmp/REPLACEMENT"

echo '/var/tmp/test' | sed 's/\/[^\/]*$/\/REPLACEMENT/' 
/var/tmp/REPLACEMENT

```
You don't need `sed` for this...`basename` and `dirname` are a better choice for assembling or disassembling pathnames. All those escape characters give me a headache....

```
param="/var/tmp/test"
param_repl=`dirname $param`/newtest

```