Posted under » Linux on 27 April 2011
less is a terminal pager program used to view (but not change) the contents of a text file one screen at a time. It is similar to more. Less is scrolling but more goes page by page. You can use cat too to view short text.
$ less -M readme.txt # Read "readme.txt." $ less +F /var/log/mail.log # Follow mode for log $ file * | less # Easier file analysis. $ less -I -p void *.c # Case insensitive search for "void" in all .c files
I often use tail -f /var/log/mail.log quite a lot when troubleshooting. However, please note that it will take a lot of memory if you don't kill the processes. So best to just see a static last 10 lines.
$ tail /var/log/mail.log $ tail -50 /var/log/mail.log # last 50 lines
If for some reason the log file is more than 1 gb, then you should break it into pieces using split.
$ split -l 15000 -d --additional-suffix=.txt --suffix-length=4 intranet.access_log_ssl intranet.access
Where 15000 is the number of lines and intranet.access_log_ssl is the original name. It will become intranet.access0001.txt