Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [tlug] grep, sed, and cat - oh my!



On Thu, Sep 16, 2010 at 07:07:09PM +0200, Nicolas Limare wrote:
...
> > ... and I thought I would need to use "grep" so that my line-replacing 
> > would happen on multiple files... but does "sed" already act on multiple 
> > files?
> 
> no. sed works line by line

yes, it works on multiple files.

mattia@example.com:~> echo 1 > f1; echo 1 > f2
mattia@example.com:~> sed 's/1/2/' -i f{1,2}
mattia@example.com:~> grep . f{1,2}
f1:2
f2:2

...
> find ./ -name *.html | while read FILE; do sed -i 's%...%...%g' $FILE; done
                    ...| xargs sed '...' -i
or just
    sed 's%la%laala%g' -i /path/to/*.html
if all files you want to work on are in the same directory.
Read sed's manpage, sed can take backups for you of all the files it
changes.
-- 
mattia
:wq!

Attachment: signature.asc
Description: Digital signature


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links