|
You can use several options to streamline the viewing of large text files, such as /var/log/messages. Some of these options are described in the article below.
# head The head command will print the first 10 lines of a file to the screen. This can be coupled with the options "-n " to display a larger number of lines. So for instance, # head -n 40 would display the top 40 lines of a text file.
# tail Much like #head, the tail command will display the last 10 lines of a text file. This can also be coupled with the option "-n " to display a larger number of lines.
# cat Cat will print the entire contents of a file to the screen.
You can also add a '| grep' to the end of any of these commands to search for a specific word. For instance,
# cat testing.txt | grep error
would only report the lines containing the word 'error'. Note that this is case-sensitive.
|
Add to Favourites
Print this Article
|