Skipping lines from the beginning of text files
June 16th, 2007
Sometimes you may need to process a text file from the unix shell excluding some lines at the beginning of the file. You can do that using the tail command:
This instructs the tail command to skip the first 4 lines and dump myfile.txt starting from the 5th line.
You can also combine tail with head to get specific lines within a specific range, for example:
This will print lines 3 to 5 to the standard output.
# tail -n +5 myfile.txtThis instructs the tail command to skip the first 4 lines and dump myfile.txt starting from the 5th line.
You can also combine tail with head to get specific lines within a specific range, for example:
# head -5 myfile.txt | tail -n +3This will print lines 3 to 5 to the standard output.