Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
Fetching specific lines from a file
Name: sandeeprk Date: May 5, 2003 at 04:24:45 Pacific OS: UNIX CPU/Ram: p2
Comment:
Hi all, I have a log file with fixed patterns as shown below:-
END(prg02,success) .... this goes on with prg03,prg04...
I need to extract cases which hav failed... here prg02 has failed. so i need 2 grep for the failures, find out the cases that have failed & then extract the lines () between start & end(only failures). Can somebody help. Thanx in advance sandeep
Name: James Boothe Date: May 5, 2003 at 07:59:55 Pacific
Reply:
prg02 also shows success. I will assume that it was suppose to say "fail".
Following code will print each group of lines that contains the string "fail". A line beginning with "START" signals the beginning of the next group of lines.
sed -e '/^START/!{H;$!d;}' \ -e 'x;/fail/!d;' logfile
The string "fail" found anywhere in the group will cause the group to be printed. Let me know if you want that tightened up to look only for "fail" within an END line.
0
Response Number 2
Name: sandeeprk Date: May 5, 2003 at 21:23:05 Pacific
Reply:
Hello james, thanx 4 the reply. prg02 should have been fail & not success. i am sorry 4 that mistake. I will just rephrase the question again ... more clearly.
1>START(prg01) 2> 3> (please note prg0x) 4> END(prg01,success) 5>START(prg02) 6> 7> 8> 9>END(prg02,fail) 1-9 are line numbers 4 u'r convinience. here, prg02 has failed , so i need to extract lines from 5 to 9.
Summary: I'm trying to remove a specific line from a file based on a user defined input. I had found a similar situation where sed was used, but when I tried using it in my script, sed had trouble with the...
Summary: i hv written a shell script which exports data to a file and i want to filter out one particular line from that file and manipulate that line further. ...
Summary: Hi All, I want to get the first line from a file and write it into another file. Please help. Thanks in advance. Regards, Raj Thanks & Regards, Raj...