need help on unix

David W. Tamkin dattier at vpnet.chi.il.us
Wed Jun 19 01:38:28 AEST 1991


guy at auspex.auspex.com (Guy Harris) wrote in <8382 at auspex.auspex.com>:

| "sed" can do a better job; if you want to remove the first N lines, try
| "sed -n 'N-1,$p'", where "N-5" needs to be computed and literally
| inserted in the command. 

If you want to remove the first N lines, you don't need to calculate N-1 nor
N-5.  You could calculate N+1 and write

sed -n 'N+1,$p'

or calculate nothing at all, do less typing, and write

sed '1,Nd'  # assuming N is an integer written in digits

Depending on your shell, if N is in a variable, you can use something like
(in sh or ksh)

sed "1,$N d"

David Tamkin  PO Box 7002  Des Plaines IL  60018-7002  dattier at vpnet.chi.il.us
GEnie:D.W.TAMKIN  CIS:73720,1570  MCIMail:426-1818  708 518 6769  312 693 0591

"Parker Lewis Can't Lose" mailing list:
 flamingo-request at esd.sgi.com (reflector)    flamingo-request at mcs.com (digest)



More information about the Comp.unix.questions mailing list