Remove previous line if next & previous lines have same 4th character.
I want to remove commands having no output. In below text file.
Code:
bash-3.2$ cat abc_do_it.txt
grpg10so>show trunk group all status
grpg11so>show trunk group all status
grpg12so>show trunk group all status
GCPKNYAIGT73IMO 1440 1345 0 0 94 0 0 INSERVICE 93% 0% ( 1 )
grpg13so>show trunk group all status
grpg14so>show trunk group all status
grpg15so>show trunk group all status
grpg16so>show trunk group all status
WHPLNYGRDS3S2B1B 336 312 0 1 0 0 0 INSERVICE 92% 6% ( 23 )
grpg1so>show trunk group all status
grpg2so>show trunk group all status
NYCMNY54DS1S8Y1O 456 453 0 0 2 0 0 INSERVICE 99% 0% ( 1 )
grpg3so>show trunk group all status
grpg4so>show trunk group all status
grpg5so>show trunk group all status
grpg6so>show trunk group all status
DRPKNYDP03TS2A1I 504 136 0 8 0 0 0 INSERVICE 26% 71% ( 360 )
NYCQNYWSCM3SWW1O 336 323 0 0 12 0 0 INSERVICE 96% 0% ( 1 )
grpg7so>show trunk group all status
grpg8so>show trunk group all status
grpg9so>show trunk group all status
mtng10so>show trunk group all status
NYCMNYBX47T1IM1I 1776 1752 0 0 0 0 0 INSERVICE 98% 1% ( 24 )
WNYKNYBCCM1SWW1I 336 22 0 5 0 0 0 INSERVICE 6% 91% ( 309 )
WNYKNYBCCM1SWW1O 336 131 0 0 0 0 0 INSERVICE 38% 61% ( 205 )
WHPLNY02CA23IM1O 720 477 0 0 29 0 0 INSERVICE 66% 29% ( 214 )
mtng11so>show trunk group all status
mtng1so>show trunk group all status
WNYKNYBCCM1SWW1I 96 0 0 0 0 0 0 INSERVICE 0% 100% ( 96 )
NYCMNY1306TS2A2I 384 336 0 0 0 0 0 INSERVICE 87% 12% ( 48 )
WHPLNY02CA0SIM1I 672 445 0 11 0 0 0 INSERVICE 66% 32% ( 216 )
mtng2so>show trunk group all status
WNYKNYBCCM1SWW1I 240 0 0 0 0 0 0 INSERVICE 0% 100% ( 240 )
WHPLNY02CA23IM1O 1080 1020 0 0 59 0 0 INSERVICE 94% 0% ( 1 )
WNYKNYBCCM1SWW1O 144 2 0 0 7 0 0 INSERVICE 1% 93% ( 135 )
mtng3so>show trunk group all status
WHPLNYWP08TS2A1I 192 191 0 0 0 0 0 INSERVICE 99% 0% ( 1 )
WNYKNYBCCM1SWW1O 192 3 0 0 9 0 0 INSERVICE 1% 93% ( 180 )
mtng4so>show trunk group all status
NYCMNY83CM2SWW1O 672 552 0 0 118 0 0 INSERVICE 82% 0% ( 2 )
NYCMNYBSDS2S2B1B 48 0 0 0 0 0 0 INSERVICE 0% 100% ( 48 )
NYCMNYBSDS0S2B1B 48 0 0 0 0 0 0 INSERVICE 0% 100% ( 48 )
mtng5so>show trunk group all status
mtng6so>show trunk group all status
DRPKNYDP03TS2A1I 48 0 0 0 0 0 0 INSERVICE 0% 100% ( 48 )
mtng7so>show trunk group all status
WHPLNY02CA0SIM1I 624 272 0 16 0 0 0 INSERVICE 43% 53% ( 336 )
mtng8so>show trunk group all status
mtng9so>show trunk group all status
NYCMNY3723TS2A1I 240 56 0 27 0 0 0 INSERVICE 23% 65% ( 157 )
nwtg1so>show trunk group all status
NWTPMOAB00T1PT1B 144 141 0 0 2 0 0 INSERVICE 97% 0% ( 1 )
nwtg2so>show trunk group all status
nwtg3so>show trunk group all status
INDPMOXCGT00WW1O 1440 1343 0 0 49 0 0 INSERVICE 93% 3% ( 48 )
nwtg4so>show trunk group all status
rpkg10so>show trunk group all status
rpkg11so>show trunk group all status
RCPKNJ02EADSVM1O 168 161 0 0 2 0 0 INSERVICE 95% 2% ( 5 )
rpkg1so>show trunk group all status
rpkg2so>show trunk group all status
NWRKNJ0205TS2A1O 120 118 0 0 1 0 0 INSERVICE 98% 0% ( 1 )
rpkg3so>show trunk group all status
rpkg4so>show trunk group all status
rpkg5so>show trunk group all status
rpkg6so>show trunk group all status
rpkg7so>show trunk group all status
rpkg8so>show trunk group all status
bash-3.2$
Last edited by Franklin52; 11-08-2012 at 07:32 AM..
Reason: Please use code tags for data and code samples
Hello,
Can anybody help me to correct my sed syntax to find the string and print previous two lines and current line and next one line.
i am using string as "testing"
netstat -v | sed -n -e '/test/{x;2!p;g;$!N;p;D;}' -e h
i am able to get the previous line current line next line but... (1 Reply)
I'll try explain this as best I can. Let me know if it is not clear.
I have large text files that contain data as such:
143593502 09-08-20 09:02:13 xxxxxxxxxxx xxxxxxxxxxx 09-08-20 09:02:11 N line 1 test
line 2 test
line 3 test
143593503 09-08-20 09:02:13... (3 Replies)
Hi all,
on Solaris 10, I'd like to print a range of lines starting at pattern but also including the very first line before pattern.
the following doesn't print the range starting at pattern and going down to the end of file: cat <my file> | sed -n -e '/<pattern>{x;p;}/'
I need to include the... (1 Reply)
Hi All,
This is very urgent, I've a data file with 1.7 millions rows in the file and the delimiter is cedilla and I need to format the data in such a way that if the NF in the next row is less than 1, it will append that value to previous line.
Any help will be appricated.
Thanks,... (17 Replies)
Hi ,
i have a file with data as below.This is same file. But actual file contains to many rows.
i want to search for a string "Field 039 00" and delete that line and previous 3 lines in that file.. Can some body suggested me how can i do using either sed or awk command ?
Field 004... (7 Replies)
Hello,
I am trying to return a time multiple times from a file that has varying output just before the time instance, i.e.
cat jumped
cat jumped
cat jumped
time = 1.1
cat jumped
cat jumped
time = 1.2
cat jumped
cat jumped
time = 1.3
In this case i would like to output a time.txt... (6 Replies)
hello everyone,
im new here, and also programming with awk, sed and grep commands on linux.
In my text i have many lines with this config:
1 1 4 3 1 1 2 5
2 2 1 1 1 3 1 2
1 3 1 1 1 2 2 2
5 2 4 1
3 2 1 1 4 1 2 1
1 1 3 2 1 1 5 4
1 3 1 1... (3 Replies)
Hi,
i have a file with multiple entries. After some tests with sed i managed to get the file output as follows:
lsn=X-LINK-IN0,apc=661:0,state=avail,avail/links=1/1,
00,2110597,2094790,0,81,529,75649011,56435363,
lsn=TM1ITP1-AM1ITP1-LS,apc=500:0,state=avail,avail/links=1/1,... (5 Replies)
Hi All,
I need to print the characters in the previous line just before the regular expression match
Please have a look at the input file as attached
I need to match the regular expression ^ with the character of the previous like and also the pin numbers
and the output file should be like... (6 Replies)