grab next consecutive line or lines


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting grab next consecutive line or lines
# 1  
Old 12-07-2006
grab next consecutive line or lines

Hello i'm writting a krn shell that will find the letter F and I would like to grab everything from F till 0:00. Is there a sed or awk command that i could use.
Thank you. File is looks like this.

11/12 xxx xxxx xxx F xxxx xxxx
some info entered here
some info entered here
xxxx 0:00 xxxx xxx S xxxx xxxx
11/12 xxx xxxx xxx F xxxx xxxx
some info entered here
some info entered here
xxxx 0:00 xxxx xxx S xxxx xxxx

All the x's have data that changes and " some info entered here" can be either 1 or more lines. Plus the whole info repeats so i would just like to capture the first occurance of it. Thanks.

Smilie
# 2  
Old 12-07-2006
Code:
sed -n "/F/,/0:00/{p;/0:00/q;}" file

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Grep three consecutive lines if each lines contains certain string

say we have : 2914 | REQUEST | whatever 2914 | RESPONSE | whatever 2914 | SUCCESS | whatever 2985 | RESPONSE | whatever 2986 | REQUEST | whatever 2990 | REQUEST | whatever 2985 | RESPONSE | whatever 2996 | REQUEST | whatever 2010 | SUCCESS | whatever 2013 | REQUEST | whatever 2013 |... (7 Replies)
Discussion started by: Saumitra Pandey
7 Replies

2. Shell Programming and Scripting

Grep 2 consecutive lines and replace the second line in a file

I have a file lake this cat ex1.txt </DISCOUNTS> <B2B_SPECIFICATION elem="0"> <B2B_SPECIFICATION elem="0"> <DESCR>Netti 2 </DESCR> <NUMBER>D02021507505</NUMBER> </B2B_SPECIFICATION> <B2B_SPECIFICATION elem="1"> <DESCR>Puhepaketti</DESCR>... (2 Replies)
Discussion started by: Dhoni
2 Replies

3. Shell Programming and Scripting

awk to grab the most found lines

awk 'NR>=5034&&/Max/{++c}c==3{o=$0 RS $0 RS $0; print o; c=0}' logfile i would like to modify the above awk command to instead show lines that are the most frequent: for instance, given a log file containing: Warning MaxClient is having issues - please MaxClients java error...yams... (4 Replies)
Discussion started by: SkySmart
4 Replies

4. Shell Programming and Scripting

Grep couple of consecutive lines if each lines contains certain string

Hello, I want to extract from a file like : 20120530025502914 | REQUEST | whatever 20120530025502968 | RESPONSE | whatever 20120530025502985 | RESPONSE | whatever 20120530025502996 | REQUEST | whatever 20120530025503013 | REQUEST | whatever 20120530025503045 | RESPONSE | whatever I want... (14 Replies)
Discussion started by: black_fender
14 Replies

5. Shell Programming and Scripting

How to insert line with between two consecutive lines that match special pattern?

I have following pattern in a file: 00:01:38 UTC abcd 00:01:48 UTC 00:01:58 UTC efgh 00:02:08 UTC 00:02:18 UTC and I need to change something like the following 00:01:38 UTC abcd 00:01:48 UTC XXXX 00:01:58 UTC efgh 00:02:08 UTC XXXX (6 Replies)
Discussion started by: jjnight
6 Replies

6. Shell Programming and Scripting

Merge two non-consecutive lines based on line number or string

This is a variation of an earlier post found here: unixcom/shell-programming-scripting/159821-merge-two-non-consecutive-lines.html User Bartus11 was kind enough to solve that example. Previously, I needed help combining two lines that are non-consecutive in a file. Now I need to do the... (7 Replies)
Discussion started by: munkee
7 Replies

7. Shell Programming and Scripting

Merge two non-consecutive lines

Hello - First post here. I need help combining two lines that are non-consecutive in a file. Using sed, awk or perl preferably. So the file looks as follows. Please note, the "Line#:" is there only for reference. The lines can only be distinguished by whether they have "start" or "done" in... (2 Replies)
Discussion started by: munkee
2 Replies

8. UNIX for Dummies Questions & Answers

want to merge two consecutive lines.

Hi All, I want to merge two consecutive lines. Currently the output is :--> crmplp1 cmis461 No Online cmis462 No Offline crmplp2 cmis462 No Online cmis463 No ... (6 Replies)
Discussion started by: pank29
6 Replies

9. Shell Programming and Scripting

script to grab lines between two values

hi guys say I have a file that contains hello world this is AAAAA message to try BBBBBB and see if anyone AAAAA knows the (3 Replies)
Discussion started by: JamesByars
3 Replies

10. Shell Programming and Scripting

Appending Consecutive lines

Hi, I have a file containing a single field on every row. What I need is to append one on to the end of another, e.g. The input file looks like this: nnnnn mmmmmm nnnnn mmmmmm I need it to look like this: nnnnn mmmmmm nnnnn mmmmmm Any ideas would be much appreciated,... (8 Replies)
Discussion started by: pondlife
8 Replies
Login or Register to Ask a Question