replace string with empty string of dir path
Hi, I want to replace a string of directory path in a string to empty:
Code:
dd="test" Code:
j=$(echo "/mnt/sda1/record/test/somefile.test"|sed 's/\/mnt\/sda1\/record\/test\///g') Thanks |
If the pattern is a variable you have to let the shell substitute it by changing single quotes with double quotes, otherwise the word $STRING is interpreted literally. If the pattern contains slashes, you might use another character as separator in the s command, e.g.
Code:
... | sed "s:$STRING::g" |
Or you could store the path and use parameter substitution:
Code:
dd="test" |
thanks!
|
All times are GMT -5. The time now is 10:46 AM. |