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

Re: substitute strings in text files (links in html files)



In <[🔎] 199901151218.NAA37760@deimos.rz.uni-osnabrueck.de>, on 01/15/99 
   at 12:39 PM, "Oliver Thuns" <oliver.thuns@gmx.de> said:

>Hello!

>How could I substitute a string (links) in html files with standard Linux
>(debian) tools?

>i.e. I want to change every http://one.domain.com in
>http://two.domain.com in some files and files in subdirs.

In using sed to do this, you may want to expand the string being sought by
sed so that you don't inadvertently change other instances of "one" to
"two."

If you do want to search for "http://one.domain"; and change it to
"http://two.domain"; then you need to "escape" the slashes, since they also
serve as control characters for sed. (The colon may too.  I don't recall
offhand, as my experience is limited.)  

This would be done as follows:
  sed s/http:\/\/one.domain/http:\/\/two.domain/g  file > file1 The "\" in
front of each "/" tells sed to treat the "/" as a regular character, instead
of a control character.

Kenward
-- 
-----------------------------------------------------------
kaynjay@igalaxy.net

What do you call a bus of lawyers headed over a cliff, with two empty seats?
   A waste of space.
-----------------------------------------------------------


Reply to: