replace path
hi guys
i have a simple question i have some variables they contain path addresses i want to replace old address with new address e.g echo $m=/tmp/files3/New/test i want to replace /tmp/files3 with /root/new i used sed but it didnt work echo $m | sed "s-/tmp/files3-/root/new" what ca i do ??? |
export m='/tmp/files3'
|
Where do you want to replace them? In a script, your environment just for this session, in your environment permanently? Where are the original values stored?
|
Quote:
???????????!!!!!!!! |
Quote:
|
Quote:
here: echo $m | sed 's/tmp\/files3/root\/new/' |
Quote:
Code:
echo $m | sed 's/\/tmp\/files/\/root\/new/' |
There's no need for sed. Once a value is in a variable, you really only need built-in parameter substitution.
Code:
m=/tmp/files3/New/test Bash also has many more string manipulation options available, and you should generally rely on them for simple operations like this. Save the external tools like sed and awk for operating on text files and other large blocks of text that need to be processed en masse. |
All times are GMT -5. The time now is 09:33 AM. |