On Fri, 2003-03-28 at 14:35, Piero Calucci wrote: > On Fri, 2003-03-28 at 15:15, ghwbush wrote: > > I have a directory of about 60 files. I want to search these files and > > replace some text. Is there an easy way to do this from a command > > line? > > for file in `ls` ; do cat $file | sed 's/search/replace/' > $file.new ; > done > > assuming you are searching for "search" and want to replace it with > "replace"
You may also want to try:
for file in `ls` ; do perl -pie 's/search/replace/' $file ; done
or, which may be better if you want your files are in various
subdirectories:
find . -type f -exec perl -pie 's/search/replace/' \{\} \;
which stands for:
find, from here, files and perform perl -pie 's....' on them
Hugs, Rui
--
+ No matter how much you do, you never do enough -- unknown
+ Whatever you do will be insignificant,
| but it is very important that you do it -- Gandhi
+ So let's do it...?
Please AVOID sending me WORD, EXCEL or POWERPOINT attachments.
See http://www.fsf.org/philosophy/no-word-attachments.html
signature.asc
Description: This is a digitally signed message part
