Wednesday, February 2, 2011
Head and Tail Commands
Today we will discuss two commands that we be very helpful when working with large files based on text. These are the commands head and tail.
Sometimes we have to open text files with a considerable size when in fact we see a few lines.
For example, a case would be to check a log or an XML file. For example, a case Would Be to check a log or an XML file.
The head command displays only the first lines of the file. By default show the first 10 lines We use it like this: We use it like this:
head file.txt
Or want to see that many lines, 15 in this example:
head -15 file.txt
To perform the opposite action there is the tail command. What makes the tail is to show the last lines of a file.
It is ideal for example to see the latest changes file in a log. By default, like head, display 10 lines: tail file.txt
If you wish to view the last 15 lines: tail -15 file.txt
Combined with the grep command (to find words in files) head and tail are a great team.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment