merlyn@iwarp.intel.com (Randal Schwartz) (03/04/90)
In article <652@sagpd1.UUCP>, jharkins@sagpd1 (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 | | But what this does is replace 'foo' with '$i', not the filename. Can anybody | help? I'm running 4.3 BSD UN*X. Thanks. Single quotes prevent the CSH from interpreting '$i'. Your solution using csh/sed is: foreach i (list of files) sed "s/foo/$i/" <$i >tmp mv tmp $i end My one-liner solution using Perl is: perl -pi -e 's/foo/$ARGV/;' list of files Just another Perl hacker, -- /=Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095 ==========\ | on contract to Intel's iWarp project, Beaverton, Oregon, USA, Sol III | | merlyn@iwarp.intel.com ...!any-MX-mailer-like-uunet!iwarp.intel.com!merlyn | \=Cute Quote: "Welcome to Portland, Oregon, home of the California Raisins!"=/