richard terry ha scritto:
> to any scripters amongst us.
>
> is there any simple bash command to remove the first  line in a file and 
> leave 
> the rest?, short of reading all the lines and re-writing the file?
>   
    tail -n+2 your_file_name

will output to standard output the file indicated, starting from the 
second line (ie, omitting the first one). It is important the plus sign, 
otherwise you will get the 'n' (n=2 in this example) last lines instead. 
You can redirect the standard output somewhere else (another file). You 
can not redirect to the same file, so you need two stages with a 
temporary file to hold the result:

        tail -n+2 your_file_name > /tmp/temporary_file; mv 
/tmp/temporary_file your_file_name

In the previous double command the file /tmp/xxx is chosen arbitrarily, 
but probably it suffices; otherwise take a look at mktemp(1); it can be 
used like this:

        tmp=$(mktemp); tail -n+2 your_file_name > $tmp; mv $tmp 
your_file_name

The above line is formed by three commands, and can be passed to a SHELL 
in gambas.

Btw, also "sed" and "awk" instead of "tail" can do this, and even much 
more, but they are heavier.

Regards,
Doriano


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user

Reply via email to