Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sed replacement

Status
Not open for further replies.

paublo

ISP
Sep 14, 2006
127
US
Hi, hoping some scripting guru here can help me out.

I have a bash script that i wrote to replace every 6th line in a file but what i really want is for it to replace certain lines only and these lines with certain keywords arent always in the 6th line.

my original script:

------------
#!/bin/bash
for LIST in *
do
sed '6c\
2008022701 ; serial\
' $LIST > ../namedtmp/$LIST
done
--------------
in the file there are many line but i need to look for these lines


2006062901 ; serial

IN NS ns1.xxx.net.
IN NS ns2.xxx.net.

and replace them with

2008022701 ; serial

IN NS ns1.ZZZ.net.
IN NS ns2.ZZZ.net.


I would really appreciate your help.
 
I'm not sure whether I got it.
Do you want to replace all occurences of 2006062901 with 2008022701?
This would do a
Code:
sed 's/2006062901/2008022701' file > file.new
.
To change all urls:
Code:
sed 's/\(ns[12]\).xxx.net/\1.ZZZ.net/' file > file.new

don't visit my homepage:
 
solved.

i actually got it working with

#!/bin/bash

for LIST in *


do
echo $LIST
sed -e '/ns2.zzz.net/ a\\t\t\tIN NS\t\tns1.append.net.' -e 's/.*serial/\t\t\t 2008022901 ; Serial/' -e 's/ns1.xxx.net/XXX.net/' -e 's/ns2.zzz.net/ZZZ.net/
' $LIST > tmpdir/$LIST

done

hope this helps someone.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top