RE: how to search/replace text in mutliple files?

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

 



Check out for in the bash shell. Specifically, from the command line you could type something like:

for FNAME in *.html ; do sed "script" $FNAME > $FNAME.new ; done

This should take each .html file in the current directory and execute the sed command against it, leaving the results in .html.new files. 

Doing multiple directories is left as an exercise for the student. :-)

----
Robert P. Nix                            internet: nix.robert@xxxxxxxx
Mayo Clinic                                  phone: 507-284-0844
RO-CE-8-857                                page: 507-270-1182
200 First St. SW 
Rochester, MN 55905      
----   "Codito, Ergo Sum" 
"In theory, theory and practice are the same,
 but in practice, theory and practice are different."



> -----Original Message-----
> From:	fedora-list-admin@xxxxxxxxxx [SMTP:fedora-list-admin@xxxxxxxxxx] On Behalf Of Trevor Smith
> Sent:	Wednesday, February 11, 2004 1:10 PM
> To:	fedora-list@xxxxxxxxxx
> Subject:	Re: how to search/replace text in mutliple files?
> 
> On February 11, 2004 09:33 am, Piero Calucci wrote:
> > btw if you are going to _replace_ text you should better look at sed or
> > perl one-liners
> 
> Dude, that was exactly the plan. But I couldn't get sed to *find* the text, 
> let alone replace it, so I concentrated on figuring out the regex (with grep) 
> and couldn't, so I emailed you. :-)
> 
> Now, how I am going to search/replace multi-line blocks of HTML in files using 
> sed? Good question. I'm afraid the power of sed has not been my friend (too 
> new to this).
> 
> -- 
>  Trevor Smith    |    trevor@xxxxxxxxxxxxxx 
> 
> 
> -- 
> fedora-list mailing list
> fedora-list@xxxxxxxxxx
> To unsubscribe: http://www.redhat.com/mailman/listinfo/fedora-list




[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux