Pausing the ls command
I know this is probably a dumb question, but since I'm
new to the Linux OS, and especially to using the Linux
command prompt, most likely this will be an easy one.
I'm a long time MS user and since I've used it since DOS 5,
I'd rather use the shell to run things, plus it gives you
more control over them.
Since I'm wanting to move to using Linux as my main OS,
I'm trying to find the equivalent to the more common
shell commands that I use. One that I'm having a problem
finding is the option for the list command 'ls' to
pause the screen after each page, the way 'dir /p' would
do in DOS. Can anyone help?
ls [Options] <your_directory_to_list> | less
Welcome to the forums! :)
The command given above by khafa should work for you.
For more information on Linux commands and working with the command line under Linux, check out LinuxCommand.org.
Below is a free online book that you can look through for additional commands:
Linux Command Directory: Index
Another option for additional information regarding commands is:
Hope you have fun with it.
Thanks for the help guys. It's working great. The links have come
in handy, too.
I want to clarify one other thing.
In the Linux shell, as I'm sure you will learn, we do a lot of work by taking the output of one command and using it as the input to a second command. This is called piping, and allows you to perform complex behaviours very simply. It also allows commands to focus on doing one thing well, because it is very easy to interweave them.
khafa's command is an example of this. "ls" lists files, and "less" (successor to an older command called "more") is a pager that reads input and allows you to navigate up and down and search for words.
So what has been done here is piping the output of ls into less. However, unlike dir /p, you can pipe anything into less. So if you're compiling a program and want to see all of the output, you can do "gcc ... | less". Or if you just want to read a file more easily than printing the whole thing at once, you can just do "less /path/to/file".
Best of luck in learning more about the Linux shell. It's a very powerful tool.