[Linux-Biella] erasefirstline

Claudio linux@bilug.linux.it
Tue, 9 Sep 2003 15:34:13 +0200


Il Tue, 9 Sep 2003 15:19:21 +0200
"CIARROCCHI Paolo" <Paolo.CIARROCCHI@vodafone.com> scrisse:

CP> Ciao a tutti,
CP> mi sono spesso trovato nella situazione di 
CP> dover rimuovere la prima linea di un file e di 
CP> printarlo a schermo.
CP> 
CP> Ho risolto il tutto con questo script:
CP> 
CP> #!/usr/bin/bash
CP> lines=$(cat $1|wc -l )
CP> cat $1|tail -$((--lines))
CP> 
CP> Esiste un modo migliore ?

Si, tail

NAME
     tail - display the last part of a file
 
SYNOPSIS
     tail [-F | -f | -r] [-b number | -c number | -n number] [file ...]
 
DESCRIPTION
The tail utility displays the contents of file or, by default, its
standard input, to the standard output.
 
The display begins at a byte, line or 512-byte block location in the
input.  Numbers having a leading plus (``+'') sign are relative to the  
beginning of the input, for example, ``-c +2'' starts the display at the
second byte of the input.  Numbers having a leading minus(``-'') sign or
no explicit sign are relative to the end of the input, for example,``-n 
2'' displays the last two lines of the input.  The default starting
location is ``-n 10'', or the last 10 lines of the input.

Bye

-- 
Per cortesia niente allegati word, solo in formato ASCII (.txt) 
oppure Rich Text Format (.rtf)
--
Linux Registered User     #151147  |  Home Page    http://www.bilug.linux.it
Linux registered Machine  #66331   |  ICQ Number   53293810
GPG key http://claudio.bmm.it/gpg/key-bilug.asc