how to search/replace text in mutliple files?
Nix, Robert P.
Nix.Robert at mayo.edu
Wed Feb 11 19:24:30 UTC 2004
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 at mayo.edu
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 at redhat.com [SMTP:fedora-list-admin at redhat.com] On Behalf Of Trevor Smith
> Sent: Wednesday, February 11, 2004 1:10 PM
> To: fedora-list at redhat.com
> 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 at haligonian.com
> fedora-list mailing list
> fedora-list at redhat.com
> To unsubscribe: http://www.redhat.com/mailman/listinfo/fedora-list
More information about the users