![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| urgent-extracting block data from flat file using shell script | shirish_cd | Shell Programming and Scripting | 4 | 02-06-2008 09:05 AM |
| Extracting Data from a File | oop | UNIX for Dummies Questions & Answers | 0 | 07-31-2007 12:48 PM |
| Extracting Data from xml file | nishana | Shell Programming and Scripting | 3 | 07-13-2007 08:17 AM |
| Extracting data from an AFP file | Dolph | UNIX for Advanced & Expert Users | 4 | 05-22-2007 05:29 AM |
| Parsing the data in a file | Omkumar | Shell Programming and Scripting | 2 | 05-20-2005 09:59 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Parsing file and extracting the useful data block
Greetings All!!
I have a very peculiar problem where I have to parse a big text file and extract useful data out of it with starting and ending block pattern matching. e.g. I have a input file like this: sample data block1 sample data start useful data end sample data block2 sample data start useful data end sample data My output shall be like following: block1 useful data block2 useful data Any help will be appreciable. Cheers Arminder |
|
|||||
|
Quote:
Code:
awk '{ if ($0 ~ "block") { print $0;getline;getline;getline;print $0 } }' testfile
Cheers ZB |
|
||||
|
Sorry Guys, maybe I didn't put it correctly. The amount of "useful data" isn't known i.e. it may be 2 lines long or 10/20/100 i.e. no same occurences. Same goes for the "sample data" too. Its only that "start" and "end" is that can tell me where to start from and where to end.
Later I figured a way to print the block and so currently I am using following in awk file: /^start/./^end/ Thereafter I grep out (grep -v) the start and end text. Cheers Arminder |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|