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
export tpath=`echo $ipath | sed -e 's/\//_/g'`
Now I need to move it into a script so I dropped the export and tried:
for ipath in $backupdirs
#replace slashes with underscores
tpath=`echo $ipath| sed -e 's/\//_/g'`
I get an error:
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?