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

filter lines in a file

Status
Not open for further replies.

shyg

Technical User
Jul 12, 2004
20
US
How can I filter out certian lines from a file? I cant use tail or head since I am not after the first or last portions of the file but specific lines say 21-30 and 33,36,40 and so on how would I filter by the line and by a group like 21-30.
 
man sed (the address,address stuff)
man awk (the NR builtin variable)

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

awk 'NR>=21&&NR<=30||NR==33||NR==36||NR==40' infile > outfile

CaKiwi
 

sed -n '21,30p;33p;36p;40p' infile > outfile
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top