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

Cutting lines from a file ...

Status
Not open for further replies.

grega

Programmer
Feb 2, 2000
932
GB
I cannot for the life of me remember how to do this ... as an example I have a 10 line file, and I want to cut out lines 4-7 into another file (by "cut out" I mean I just need a copy of them, not remove them from the original file)

Is there a command for this? cut seems to suggest it is possible if you don't supply a switch, but my version expects a switch (-b, -n or -f) ... Solaris 2.5.1.

Greg.
 
Greg,

Try this:

sed -n '4,7p' file > newfile

this will print lines 4 to 7, works in /bin/sh

Tony
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top