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.
- 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.