Freitag, 8. April 2011

Shell 003: Tail

All but the top 40 lines of a file can be catted to a new file by calling:

count=`cat file.dat|wc -l`
tail -n -$((count-40)) file.dat > newfile.dat

Notice the backtics to evaluate the cat and wc calls in the first line. Also notice the '-' sign in front of the numeric argument to the tail command.

Keine Kommentare:

Kommentar veröffentlichen