bash script to replace char in variable
I have a variable $ipath that contains a path "/usr/local" which I need to convert to "_usr_local"
I built the following at the shell prompt to do this Code:
export tpath=`echo $ipath | sed -e 's/\//_/g'` Now I need to move it into a script so I dropped the export and tried: Code:
for ipath in $backupdirs line 30: syntax error near unexpected token `tpath=`echo $ipath| sed -e 's/\//_/g'`' Can you help me fix this or suggest a better approach? |
I hate answering my own posts. Problem was I added the sed code between the 'for' and the 'do'. Moving it to after the 'do' worked.
Sorry |
This _should_ work...
Code:
do |
Thanks ranger_nemo
|
tpath=`echo -e ${ipath//:/\_}`
HTH :) <EDIT> Oops... tpath=`echo ${ipath//\//_}` |
Thanks, folks - problem solved AND I learned something
|
All times are GMT -5. The time now is 08:46 AM. |