I have a string "\/scratch\/databases\". I want
to have a new string "\/scratch\/databases" by cutting last '\' character using shell script. I can't do this
Please help me.
Thanks in advance
ThuongTranVN
[Edited by ThuongTranVN on 01-26-2001 at 01:35 PM]
You must use a \ in front of the \ to make it a \\ in your search and replace functions because of the special nature (meta) of the \ char. Example in vi editor:
:%s/\\$//
The fragment above says "search for the \ at the end of a line and replace with nothing"
Note. that I've not tested the fragment above and it might need some more tweaking to work.
Hello,
Thank you so much for your reply.
I tried
Code:
:%s/\\$// don't replcae '\' character at the end of line
:%s/\\// replace only first '\' character of line
:%s/\\//g replace all '\' characters of line.
Thank you so much for your help.
I've got it as follows:
FOO="\/scratch\/databases"
echo $FOO | sed 's/\\$//' > tmp.log
DAEHOME=`cat tmp.log`
I can not use
DAEHOME=`echo $FOO | sed 's/\\$//'`