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!

Display output on certain lines 1

Status
Not open for further replies.

pho01

Programmer
Mar 17, 2003
218
US
Does anybody know of an unix command to display output of a file on certain lines?

For example, i want to copy lines 406-1933 of a file to another file. I can't think of a way to strip it out, does anybody know if unix can do it.
 
Try...
Code:
awk 'NR>=406 && NR<=1933' file1 > file2
 
Another way:
sed -n '406,1933p' /path/to/input > output

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
futurelet,

I think you meant...
Code:
awk 'NR=[highlight]=[/highlight]406,NR=[highlight]=[/highlight]1933' file1 > file2
 
Thanks everybody. Unfornately, there is some line_max that can't display more than certain lines. On my machine, it only displays 1122 lines, the text got cut after that.

does anybody know how to increase the line max?
Thanks!
 
Ygor said:
I think you meant...
Code:
awk 'NR==406,NR==1933' file1 > file2
True.

pho01 said:
On my machine, it only displays 1122 lines, the text got cut after that.
I can't understand that. The program can't run out of memory.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top