[sclug] Escaping slashes in bash
Peter Brewer
p.w.brewer at reading.ac.uk
Tue Sep 27 16:23:02 UTC 2005
Dear SCLUG
Having some problems with escaping "/" in Bash. We want to run perl
-pie in a bash script but have had to first put the substitution string
into a variable otherwise it doesn't get created properly. This works
fine when there are no "/" in the substitution string but how do we get
it to work if there IS a "/"????
e.g:
WORKDIR="/tmp"
LOCALITIESFILE="foobar.txt"
CMD="s/\[LOCALITIESFILE]/${WORKDIR}\/${LOCALITIESFILE}/g"
`perl -p -i -e ${CMD} ${FILENAME1}`
Many thanks once again for your combined help!
Cheers
Pete
More information about the Sclug
mailing list