shell script question
Tim Evans
tkevans at fallst.UUCP
Sun Mar 4 22:08:59 AEST 1990
In article <652 at sagpd1.UUCP>, jharkins at sagpd1.UUCP (Jim Harkins) writes:
> I have a list of files in which I want to change the word 'foo' to the filename.
> What I tried to do was
>
> foreach i (list of files)
> sed 's/foo/$i/' < $i > tmp
> mv tmp $i
> end
>
Try sed "s/foo/$i/" < $i > tmp
The single quotes in your command don't allow variable substitution. The
shell ignores any otherwise special characters inside single quotes.
--
UUCP: {rutgers|ames|uunet}!mimsy!woodb!fallst!tkevans
INTERNET: tkevans%fallst at wb3ffv.ampr.org
Tim Evans 2201 Brookhaven Ct, Fallston, MD 21047 (301) 965-3286
More information about the Comp.unix.questions
mailing list