The Linux commands
less are similar to
cat, but with
less you can scroll the file instead of showing the enter file at once. So if you have larger files you want to view that are longer than your screen or terminal then you can use
less commands instead of
I would suggest using
less more often than
more as the Linux
less command can load files to the screen faster. If you do
more somefile.txt the entire file must be read before it will start displaying on your screen. If you use
less somefile.txt the contents of
somefile.txt will be displayed as they are read from the file, so you don’t have to wait until the entire contents are read before you can see it!
Another reason I would suggest using the Linux command
less more than the Linux command
more is because with
less command you can scroll up in the file as well as down, where with the Linux command
more you can only scroll down the file. If you pass something with
more you have to quit, run the
more command again, and hope you don’t pass what you were looking for again.
The syntax for
more is like most Linux commands:
more [OPTIONS] [filename]. The sytax for
less is the same:
less [OPTIONS] [FILENAME].
The only options I use normally with
less -N [FILENAME] which will print line numbers before each line. The only options I use on
more +[number] [FILENAME] which will start you on line [number].
Now for some examples of
If I wanted to view file
phone-numbers.txt to write them down on paper, or enter into my cellphone, I could run
more phone-numbers.txt and hit enter to scroll down after I have already entered the information on my cellphone or wrote them down on paper.
If I was working on a php/mysql website and I click on Login which takes me to login.php and I get something like:
PHP parse error : syntax error, unexpected T-STRING on line 130 in file /home/user/www/login.php I can then run
more +130 /home/user/www/login.php which will start me on line 130 where the error is so I can look for what is wrong and then fix it.
Now for some examples of
If I was working on a php/mysql website and I was writing a
foreach() loop on my php script and needed a little help from someone that has a copy of my script, I could do
less -N some-script.php and tell him or her what lines I was having problems with.
Well that’s it for the Linux
less commands. As always I hope this Linux tutorial on the Linux
more commands has helped you understand
less a bit more! Thank you for reading my Linux tutorials on Beginner Linux Tutorial, I hope you have a great day! Any questions of problems with
less can be asked below in the comment section.