Path: utzoo!censor!geac!torsqnt!jarvis.csri.toronto.edu!rutgers!cs.utexas.edu!samsung!aplcen!wb3ffv!fallst!tkevans From: tkevans@fallst.UUCP (Tim Evans) Newsgroups: comp.unix.questions Subject: Re: shell script question Summary: Use double quotes to protect variable name Message-ID: <1598@fallst.UUCP> Date: 4 Mar 90 12:08:59 GMT References: <652@sagpd1.UUCP> Organization: Fallston, MD Lines: 18 In article <652@sagpd1.UUCP>, jharkins@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@wb3ffv.ampr.org Tim Evans 2201 Brookhaven Ct, Fallston, MD 21047 (301) 965-3286