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

Re: [SLUG] search and replace



Dean Hamstead wrote:
> Is there a command in vi or somesuch standard cli editor to search and
> replace
> in my case change all ".org" entries to ".com" in the dns files
> im sure awk or seomthing can do it also....

cat your_dns_file | sed 's/\.org/\.com/' > new_dns_file

The \. escapes the dot and the dot is there so that names
like www.organ_society.org don't end up as
www.coman_society.com

If you want to do it for ALL files in the directory then use
#!/bin/sh
for i in *; do
	cat $i | sed 's/\.org/\.com/' > $i.new
done

You'll prob need to somehow select what files you want
processed based on their name or extension or contents
rather than selecting all files as above.

Mike

--------------------------------------------------------------------
Michael Lake
University of Technology, Sydney
Email: mailto:Mike.Lake@nospam.uts.edu.au Ph: 02 9514 1724 Fx: 02
9514 1628 
URL: http://www.science.uts.edu.au/~michael-lake/
Linux enthusiast, active caver and interested in anything
technical.
--------------------------------------------------------------------
--
SLUG - Sydney Linux Users Group Mailing List - http://www.slug.org.au
To unsubscribe send email to slug-request@nospam.slug.org.au with
unsubscribe in the text