How to view or display contents of a file in linux one screen at a time?
more and less are paging commands used in Unix/*nix systems to display contents of a file one screen at a time. The difference between more and less is that, less supports both forward and backward navigation through a file. Whereas more supports forward navigation but backward navigation is very much limited.
more
more is primitive of the two commands. Originally more supported only forward navigation in a file but the more recent version supports limited backward navigation.
Syntax for more is
more [options] filename
more ReadMe.txt
more ReadMe.txt
less
less is the opposite of more. It supports both forward and backward navigation. less command is very much useful when the input file size is very large. This is because, unlike text editors less don't have to read the entire file. So less will start displaying the file much more faster at the same time utilizing lesser resources.
Syntax for less is similar to more
less [options] filename
less ReadMe.txt
less ReadMe.txt
Apart from files, more and less can be used along with pipes. For example to long list all files in /etc one screen at a time, type:
ls -l /etc | less
Sample Screenshot:
You can navigate through the list in a similar way you can navigate through a text file.
For all options and interactive commands that can be used along with more and less refer the corresponding man pages.
Comments
Post a Comment