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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

awk command... 1

Status
Not open for further replies.

lambros

Programmer
Oct 10, 2002
42
US
Hi,

Is there a command in awk that I can use to skip up for example 7 lines from where the current record is being processed?

Thanks,
Lambros
 
# if your RS [RecordSeparator] is NL [by default]
lines2skip=7;
for (i=1; i <= lines2skip; i++)
getline; vlad
+---------------------------+
|#include<disclaimer.h> |
+---------------------------+
 
or

lines2skip=7;
for (i=1; i <= lines2skip; i++)
next; vlad
+---------------------------+
|#include<disclaimer.h> |
+---------------------------+
 
Vlad,

The next statement reads the next input record and starts again at the first pattern in the awk script, so your second solution will not work. Your getline solution works fine, of course. CaKiwi
 
that's right - I should've gone for fresh air instead of the second posting! [wink]

thanks, CaKiwi vlad
+---------------------------+
|#include<disclaimer.h> |
+---------------------------+
 
I'm sure it was a deliberate error just to see if anyone was paying attention or perhaps to let them have a feeling of smug satisfaction when they pointed it out. :) CaKiwi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top