whats the use of less & more commands in shell programming???
can anyone help......
I hav read on net but i didnt get how to use it.........

Recommended Answers

All 2 Replies

Okay, it's good that you're interested!

Let's take an example:
You have a file which is 1Gb in size. You know that opening the file in the shell (e.g using 'cat') is going to be inefficient, as you'll have to scroll through a lot of lines to get to where you want to look. So less and more are basically alternatives to save resources and/or to only select the information that you're interested in.

The default behaviour of more is that the file content scrolls up one screen height at a time, and the space bar is used to advance to the next page. The command less is a more sophisticated version of more. Less can scroll backwards and has many more options over more. (There is plenty of information about this on the web).

If you're viewing a large log file and are only interested in what's happened most recently, then I would usually recommend using 'tail -f file.log' which would display the last 'x' number of lines of that file.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.