Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 04-17-2004, 06:48 PM   #1
LQ Newbie
Registered: Apr 2004
Location: sunny southern california
Distribution: gentoo
Posts: 10

Rep: Reputation: 0
The most basic question this forum has ever seen

How do I limit the output from ls (or any program for that matter) so that I can read a bit of it, and then hit enter to have more scroll onscreen. I am often frustrated by ls giving me an output that is mostly unreachable.
Old 04-17-2004, 06:59 PM   #2
LQ Newbie
Registered: Apr 2004
Posts: 5

Rep: Reputation: 0
I'm a newbie myself, but try "piping" it to less

ls *.sh | less
Old 04-17-2004, 07:04 PM   #3
LQ Newbie
Registered: Mar 2004
Distribution: Slackware 9.1
Posts: 12

Rep: Reputation: 0
just do "ls |more"

or "ls -l |more"
Old 04-17-2004, 07:45 PM   #4
Registered: Mar 2004
Location: Denmark
Distribution: Gentoo, Slackware
Posts: 333

Rep: Reputation: 30
You should also be able to use Ctrl+PageUp / Ctrl+PageDown to scroll the output so that you can go back and see things that you missed. If your console is an X window, then you will even have a scroll bar. This makes less / more unnecessary as you can happily scroll back to see anything you might have missed.
Old 04-17-2004, 07:46 PM   #5
Senior Member
Registered: Apr 2001
Location: Plymouth, England.
Distribution: Debian + Ubuntu
Posts: 4,358

Rep: Reputation: 57
For a more technical explanation:

With Linux shells (the command line environment) you can redirect the output from a command to somewhere else. This may be a file or another programme. Programmes can also take the input from a redirection, instead of (for example) the keyboard. So, for example, if you wanted to create a file whose contents were that of the command "ls" you'd do this:
$ ls > filename.txt
If you wanted to list the contents of a file, you could do this for example:
less < filename.txt
You can also do something in Linux that give real power: you can pipe things from one to another. So, for instance, you can take the output of ls and use it as the input for less in the examples above:
ls | less

The real power of this system becomes apparent when you have multiple things piped from one to another. An example that I can think of would be converting from one image type to another without using an image editor.
Old 04-17-2004, 09:23 PM   #6
Senior Member
Registered: Nov 2003
Location: NB,Canada
Distribution: Something alpha or beta, binary or source...
Posts: 2,280
Blog Entries: 4

Rep: Reputation: 47
yep. you have "less" "more" and "most" for sure. They all behave quite similarly. If you want output a page at a time, you should use these programs. Spacebar or pagedown make the next page appear and pageup makes it go back.
Old 04-18-2004, 01:57 AM   #7
LQ Newbie
Registered: Apr 2004
Location: sunny southern california
Distribution: gentoo
Posts: 10

Original Poster
Rep: Reputation: 0
Thanks very much, everyone.
Old 04-18-2004, 11:34 AM   #8
Registered: Apr 2004
Location: amsterdam
Distribution: Debian (Sarge and Woody)
Posts: 49

Rep: Reputation: 15
don't forget to use your arrows-keys
and if you've had enough of it, press q to return back to the command line


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
A really basic question jimscafe Debian 14 01-09-2004 06:44 PM
Basic C++ question ooagentbender Programming 10 12-10-2003 09:34 PM
very basic question Louisa Linux - Newbie 4 08-31-2003 02:05 PM
Basic Questions to the Forum Herbertt Linux - Newbie 5 03-12-2003 01:16 PM
A really basic question pilotgi Linux - Newbie 10 10-14-2002 04:57 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:06 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration