Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find the first pattern then continue

Status
Not open for further replies.

frangac

Technical User
Feb 8, 2004
163
ZA
Hi All,

I am looking for a solution for when a pattern is repeated in the same line, that it only recognises the first, and then allows me too print fields too my liking for eg

cat file | awk '{for (e=1;e<NF;e++){if (match($e,&quot;[n,d][v,g,s,f][0,2]|,[n,d][v,g,s,f][0,2].&quot;)){if($2==A||....etc

ps: that the pattern is in different fields.

Thanks in advance
Chris
 
The next statement will cause awk to read the next line when you have completed all the processing you want to do on the current line.

Also, you can eliminate the cat by having awk read the file directly

awk '{...}' file

CaKiwi

&quot;I love mankind, it's people I can't stand&quot; - Linus Van Pelt
 
Hi CaKiwi,

Thanks for your responce.

My awk line looks like this
cat $1 |awk '{if($0~/^<AT/){getline;next;getline;next;getline;next;}}/^S7 A/{printf &quot;\n%s %s&quot;,sep,$0;sep=&quot;\n&quot;;next}{print
f &quot; %s &quot;,$0}' | cut -b1-3,50-100,110-125,150-400,500-800 | awk '{for (e=1;e<NF;e++){if (match($e,&quot;[n,d][v,g,s,f][0,2][
1,9,3]|.[n,d][v,g,s,f][0,2][1,9,3].&quot;)){if($27==&quot;A&quot;||$37==&quot;D&quot;||$39==&quot;D&quot;||$54==&quot;1&quot;){{un=$36}{da=$26}{dur=$38}{bnum=$29}{printf &quot;%....etc&quot;

Where do I place the &quot;next&quot; statement

Thanks
Chris

 
Hi CaKiwi,

Got it. Getting tired.

Thanks Again.
Chris
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top