Operating System - HP-UX
1831360 Members
2643 Online
110024 Solutions
New Discussion

awk and print certain lines

 
Ahmed ABDOU_1
Advisor

awk and print certain lines

how to use awk to print lines starting from 746
upto 1000 from a text file, the file is 2000 lines. please send answer directly to
fafeef@alfaisaliah.com
7 REPLIES 7
hpuxrox
Respected Contributor

Re: awk and print certain lines

Mohmmed,

Replies should be posted to the forums not direcly by email. This is so everyone can see the Resolution to the problem, not just you.

Thanks,

Yates
Sridhar Bhaskarla
Honored Contributor

Re: awk and print certain lines

Mohmmed,

I would use sed to that job for me.

sed -n '746,1000p' yourfile

-Sri
You may be disappointed if you fail, but you are doomed if you don't try
A. Clay Stephenson
Acclaimed Contributor

Re: awk and print certain lines

That's quite simple:

awk '{if (NR >= 746 && NR <= 1000) print $0}' < myfile
If it ain't broke, I can fix that.
MANOJ SRIVASTAVA
Honored Contributor

Re: awk and print certain lines

Hi Mohmmed AbdulSattar



cat a |sed -n "746,1000p"


should give you the answer. Why are you using awk , it is easier for sed to handle this.


Manoj Srivastava
H.Merijn Brand (procura
Honored Contributor

Re: awk and print certain lines

perl -ne '746..1000 and print' text_file
Enjoy, Have FUN! H.Merijn
Deepak Extross
Honored Contributor

Re: awk and print certain lines

Yet another..
head -1000 | tail -254
Suhas_3
Advisor

Re: awk and print certain lines

Hi

awk 'NR >= 746 && NR <= 1000' filename

OR

head -1000 filename | tail +746

will work

regards,
Suhas