[ale] find/replace ever instance of X with Y in *

Pete Hardie pete.hardie at gmail.com
Mon Jan 22 20:05:05 EST 2007


On 1/22/07, Jim Popovitch <jimpop at yahoo.com> wrote:
> On Mon, 2007-01-22 at 18:34 -0500, Pete Hardie wrote:
> > then sed -e "s/X/Y/g" <shell expressiong firl all files Z>
>
> Are the angle brackets above for shell redirection or are they being
> used to describe a file spec option?  If the latter, then won't sed
> output to STDOUT?  You words "shell expressiong firl all files Z" leave
> me unsure how to take them. ;-)

Mea culpa.  I forgot that when addressing Unix users, <, and > are
meaningful...:->

Once more, with feeling:

sed -ibak -e "s/X/Y/g" $j

if you have the FSF sed - the -ibak option does in-place replacement,
with a backup copy named filename.bak, and treats files separately.

If you don't have GNU sed, then this
for J in Z
do
sed -e "s/X/Y/g" $j > $j.bak
cp $j.bak $j
done

will do the same.

>
> -Jim P.
>
>
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://www.ale.org/mailman/listinfo/ale
>
>
>


-- 
Pete Hardie
--------
Better Living Through Bitmaps



More information about the Ale mailing list