Extract data segment using awk??


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Extract data segment using awk??
# 1  
Old 07-26-2004
Extract data segment using awk??

How do I filter a long report, with the "STARTWORD" and "STOPWORD" as the variables to use in my awk command, to print the whole data segment that only contains the matched start/stop word?

awk '/start/, /stop/' file <- this prints the line, though I need to print the whole segment. Newline separates each data segment.

Thanks and good to be back,

Apalex

---------------
Report below:
----------------

Time Stamp line Data1(no common string)
STARTWORD.................STOPWORD
Nextline
Nextline

Time Stamp line Data2 (no common string)
NOTNEEDED REPORT.................WORD
Nextline
Nextline

Time Stamp line Data3 (no common string)
STARTWORD.................STOPWORD
Nextline
Nextline

Time Stamp line Data4 (no common string)
NOTNEEDED REPORT.................WORD
Nextline
Nextline

Time Stamp line Data5(no common string)
STARTWORD.................STOPWORD
Nextline
Nextline
# 2  
Old 07-27-2004
I don't think I understand entirely, but you can try this...
Code:
 awk -v RS='' '/START.*STOP/{print $0 "\n"}' file1

When RS is null then awk uses blank lines to separate records, so the result is...

Time Stamp line Data1(no common string)
STARTWORD.................STOPWORD
Nextline
Nextline

Time Stamp line Data3 (no common string)
STARTWORD.................STOPWORD
Nextline
Nextline

Time Stamp line Data5(no common string)
STARTWORD.................STOPWORD
Nextline
Nextline
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk used to extract data between text

Hello all, I have a file (filename.txt) with some data (in two columns X and Y) which looks like this: ########## 'Header1' 'Sub-header1' X Y xxxx.xx yyyy.yyy xxxx.xx yyyy.yyy .... ... 'Sub-header2' X Y xxxx.xx ... (7 Replies)
Discussion started by: jaldo0805
7 Replies

2. Shell Programming and Scripting

extract the data using AWK command

In a file i have a data like INPUT: no,name,company 1,vivek,hcl 2,senthil,cts 1,narsi,hcl 4,prabhakaran,ibm OUTPUT: 1,vivek,hcl 1,narsi,hcl Using AWK command i want to display the names those having no:1 and company:hcl.Please tell me the command to display above result. (8 Replies)
Discussion started by: katakamvivek
8 Replies

3. Shell Programming and Scripting

extract data with awk

i have a following output file PF Release 2.4 on SERVICE at Mon Feb 6 18:41:02 2012 ---------------------------------------- ---------------- |pPF |SEP |CAPS |CALLS |OPEN | |-------------------------------------------------------------| | 0 ---... (1 Reply)
Discussion started by: gauravah
1 Replies

4. Programming

Data segment or Text segment

Hi, Whether the following piece of code is placed in the read-only memory of code (text) segment or data segment? char *a = "Hello"; I am getting two different answers while searching in google :( that's why the confusion is (7 Replies)
Discussion started by: royalibrahim
7 Replies

5. UNIX for Dummies Questions & Answers

Help Using awk to Extract Data

Hi. Im new to UNIX also in programming language which in need help to output like what was I indicated using either awk shell programming or combination of some commands. Correct me if im in the wrong section. Thanks in advance. Input 101 The quick brown fox jumps over the lazy dog 99... (9 Replies)
Discussion started by: bankai29
9 Replies

6. Shell Programming and Scripting

Extract Data - awk

I need to extract columns but the way it should be stored in a file is different.I can simply do a cut -f3,2 filename but the problem is even if i do it so and the values in column 2 are string then col 2 would be appear before col3 I tried awk but using the substr i think its not possible to... (8 Replies)
Discussion started by: dinjo_jo
8 Replies

7. AIX

data segment on AIX

Hi guys, Are all users authorised to modify the data segment and stack segment to unlimited on AIX? Is a reboot required after giving ulimit -d unlimited? Thanks vandi (2 Replies)
Discussion started by: vandi
2 Replies

8. UNIX for Advanced & Expert Users

set Ulimit data segment to Unlimited

Hi, as per my Unix admin all parameters in Ulimit are set to Unlimited in Hard limits but some how few profiles setting data segment part to limited number value. So i wanted to over write in my profile to set unlimited as hard limits are set to unlimited. What is the command to set ulimit for... (1 Reply)
Discussion started by: terala_s
1 Replies

9. Shell Programming and Scripting

extract segment

Hey all, could someone please direct me on how to extract a segment from a file between two tags? Thanks! (1 Reply)
Discussion started by: mpang_
1 Replies

10. Programming

bss(uninitialized data) segment allocation

Hi 1) Please go through the following code : char string2; char string1; main() { memcpy(string2,"SENDER ",12); strcpy(string1,"******"); printf("%s\n%s\n",string1,string2); } 2) and the output of... (7 Replies)
Discussion started by: karimulla_sha
7 Replies
Login or Register to Ask a Question