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

Hi everybody: Could anybody tell

Status
Not open for further replies.

tonivm

Technical User
Mar 2, 2006
64
ES
Hi everybody:

Could anybody tell me how I can print from a file a selected rows with awk. In my case I only want print in another file all the rows from NR=8 to NR=2459 and the increment each 8 times.

I tried to this:

awk '{for (i=8; i=2459; i+=8); NR==i}' file1 > file2

and

awk 'NR%8==0 && NR<=2459' file1 > file2

But doesn't work.
Thanks in advance.
 
Hi

You are talking about rows then use [tt]NR[/tt] ( Number of Records ) which usually means lines.

Please clarify that ambiguity.

If you have problem explaining this in English, feel free to draw it.


Feherke.
 
awk 'NR%8==0 && NR<=2459' file1 > file2

works for me...

what awk/system are you on? If Windows try double quotes

awk "NR%8==0 && NR<=2459" file1 > file2


HTH,

p5wizard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top