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!

Delete lines from a file 1

Status
Not open for further replies.

panpol

Programmer
Oct 25, 2005
7
CY
Hi,
I have a file with 2 numbers, for example:

215
816

Can I use the numbers of this file, to delete some lines of one other file with the use of sed,awk,…?Is there a way to pass this numbers as parameters to sed or awk and delete the lines from 215 to 816 of one other file?

Thanks
 
A pure legacy unix way (;-)) :
sed "`paste -sd, /path/to/numbers`d" /path/to/otherfile

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Code:
NR < 3 { limits[NR] = $0 ; next }
FNR==limits[1], FNR==limits[2] { next }
8
[tt]awk -f skiplines.awk limits.txt infile >outfile[/tt]
 
PHV that is what i call efficient one-line-coding :))

great idea !
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top