[H-GEN] Text Search and Replace @ shell prompt

Greg Black gjb at gbch.net
Sun Aug 25 19:58:13 EDT 2002


[ Humbug *General* list - semi-serious discussions about Humbug and     ]
[ Unix-related topics. Posts from non-subscribed addresses will vanish. ]

| All I want to do is that searching a string and replace it with a given string in the content of the file.

That's still a very long line and the message was once again
multipart with all the html junk in it.

To give an example answer to the question, which is probably not
quite adequate because the task is under-specified, you could do
the following with ed to replace all instances of "foo" with
"bar" in all the html files in the current directory:

    $ for f in *.html ; do echo 'g/foo/s//bar/gp
    > wq' | ed $f ; done

This will print all the changed lines so that you can see what
happened.  The changes to suit the specific requirements should
be self-evident.

Greg

--
* This is list (humbug) general handled by majordomo at lists.humbug.org.au .
* Postings to this list are only accepted from subscribed addresses of
* lists 'general' or 'general-post'.  See http://www.humbug.org.au/



More information about the General mailing list