Search Results

Search: Posts Made By: ocramas
12,723
Posted By msabhi
perl -lne '{if(/SNMP-ST/){$#A=-1;$f=1;} ...
perl -lne '{if(/SNMP-ST/){$#A=-1;$f=1;}
if(/IP/){$f=(/1\.1\.1\.1/)?1:0;}if(/SNMP-END/ && ($f)){print join("\n",@A,$_);next}($f)?push(@A,$_):next;}' input_file
12,723
Posted By msabhi
awk '/IP *= *1\.1\.1\.1/ {print;while($0!~...
awk '/IP *= *1\.1\.1\.1/ {print;while($0!~ /SNMP-END/){getline;print;}}' input_file

or
as Don Cragun has pointed out use nawk

nawk '/IP *= *1\.1\.1\.1/ {print;while($0!~...
12,723
Posted By Yoda
Can't you simply run below command and get rid of...
Can't you simply run below command and get rid of lines starting with IP and ending with *:-

cat input | egrep -v "^IP|\*$"
12,723
Posted By Don Cragun
This seems to print all of the lines you have...
This seems to print all of the lines you have labeled above as "some text here":
awk '/^IP = 1\.1\.1\.1$/{copy=1;next} /SNMP-END/{copy=0;next} copy' in
Showing results 1 to 4 of 4

 
All times are GMT -4. The time now is 07:10 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy