25 October 2011

bash: skip X lines of a file or command output

If you wish to cat a file or remove the first X lines from a command output, you can use the tail command, this way:
tail -n+(X+1)
So if you would like to skip the first line, the command will be: “tail -n+2” (X=1). For the 3rd line, the command will be: “tail -n+4” (X=3).

No comments:

Post a Comment