I had to code in to remove a host entry from hosts.cfg file of nagios. Here is a bit of superb code to do so..
sed '/#/{:a;N;/\}/!ba;/212.217.202.112/s/#.*\}//;}' hosts.cfg
That will remove the entire block starting with "# '212.217.202.112' host definition" and ending in "}"
Obfuscated code eh ? Not so..learn about registers in sed!!
Showing posts with label sed. Show all posts
Showing posts with label sed. Show all posts
Sunday, November 25, 2007
Multiline search and replace using sed
Posted by
HJKL a.k.a h2l
at
1:46 AM
0
comments
Labels: bash scripting, Linux, sed
Subscribe to:
Posts (Atom)