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

```
It's not clear whether `param` is part of the string that you need processed or it's the variable that holds the string. Assuming the latter, you can do this using only Bash (you don't say which shell you're using):

```
shopt -s extglob
param="/var/tmp/test"
param="${param/%\/*([^\/])//new_test}"

```

If `param=` is part of the string:

```
shopt -s extglob
string='param="/var/tmp/test"'
string="${string/%\/*([^\/])\"//new}"

```