Viewing log files without using vi or any other text editor
2010-01-16
129 words
1 min read
This is quite useful for viewing files without opening them.. Saves quite a lot of time in viewing the logs π
Want to see the first 5 lines of the /etc/passwd file? Pretty easy, just use the "head" command:
head -5 /etc/passwd
Want to see the last 20 lines of the /etc/passwd file? Again, pretty easy, just use the "tail" command:
tail -20 /etc/passwd
But what if you only want to see lines 10-15 of a given file? Neither the "head" nor the "tail" commands alone will do. Instead, use the "sed" command to print the range of lines you want to see:
sed -n '10,15p' /etc/passwd
This command works great, even if you want to see a few lines somewhere in the middle of a 100,000 line file.
Related Articles:
- 2010/01/16 View information on all the rpms installed.
- 2010/01/16 Browser and OS stats on my blog
- 2010/01/10 Remove Invalid characters in Filename.
- 2010/01/07 Sendmail host map failure issue with sendmail.
- 2010/01/03 Finding all the executables/binary in Linux rpm based distro.
Authored By Amit Agarwal
Amit Agarwal, Linux and Photography are my hobbies.Creative Commons Attribution 4.0 International License.