[prog] using sed on multiple files

Finne Boonen hennar at gmail.com
Sat Jul 9 04:19:25 EST 2005


sed -i will change the file you're working on, without giving you
output, if that doesn't work:

maybe something along these lines helps: edit the file with sed, and
save it in a temp file, at the end (but still in the for loop) move
the temp file to the original name, effectivly updatign the original
file:

for i in ./;
  do
  sed "s/exp1/exp2/" $i > $i-new;
  mv $i-new $i;
done;

Finne


On  7/8/05, Nicki Handy <nicki at virtualnicki.com> wrote:
> Hi, I want to use the sed command on multiple files so that I can
> replace a piece of text in each of the files. The problem is the
> output- I can run the command fine on the whole directory but I don't
> want to have to specify the file to output, I just want it to change
> the file it's on.
>
> For example, this works.....
> machine# find ./ -type f -exec sed -e 's/051201/081201' {} \;
>
> But I need it to permanently make the change not just spit the output
> to STDOUT
> I can add a w but it needs to be dymanic
>
> # find ./ -type f -exec sed -e 's/051201/081201/w' {} \;
>
> Anyone know how to accomplish this?
>
> Thanks,
> Nicki
>
>
> _______________________________________________
> Programming mailing list
> Programming at linuxchix.org
> http://mailman.linuxchix.org/mailman/listinfo/programming
>


--
"Maybe you knew early on that your track went from point A to B, but
unlike you I wasn't given a map at birth!" Alyssa, "Chasing Amy"
http://hekla.rave.org/cookbook.html - my crossplatform dieet/recipe app


--
"Maybe you knew early on that your track went from point A to B, but
unlike you I wasn't given a map at birth!" Alyssa, "Chasing Amy"
http://hekla.rave.org/cookbook.html - my crossplatform dieet/recipe app


-- 
"Maybe you knew early on that your track went from point A to B, but
unlike you I wasn't given a map at birth!" Alyssa, "Chasing Amy"
http://hekla.rave.org/cookbook.html - my crossplatform dieet/recipe app


More information about the Programming mailing list