Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In some directories there are quite a few files. When I use ls the output is more than my terminal can handle. Typically I just use one of the following:

ls | less
ls | more

depending on my mood. However, I lose the color coding and I only get a single file/directory per line. Is there a way to emulate scrolling through my terminal with my mouse after I use ls without actually having to scroll? I checked the man page for ls and I didn't see anything that would allow for this but I may have missed something.

share|improve this question
up vote 11 down vote accepted

You want ls -C --color=yes | less -R. -C forces ls into multi-column mode even when it's being piped, --color=yes forces ls to always output in color, even when being piped, and the -R argument to less forces it to interpret raw terminal escape codes.

In the general case, you might also consider GNU Screen if your terminal isn't configured to support hotkeys like Michael Mrozek mentioned.

share|improve this answer
Precisely what I was looking for. Thank you. – Dason Feb 9 '11 at 22:56
Interesting. I have never seen --color=yes; I always used color=always or color=auto. – J. A. Corbal May 30 '13 at 13:29

ls doesn't control scrolling through the terminal output, your terminal does; by the time you're doing that ls has already terminated. Your terminal probably supports a hotkey to handle it; Page Up and Shift+Page Up are common choices

share|improve this answer
Good answer and Shift + Page Up works but I was hoping to keep the keybindings of something like less so I don't need to go over to pageup/pagedown to scroll. – Dason Feb 9 '11 at 22:57
Might I point out that switching over to the mouse is generally even more movement than going to pageup. At any rate it sure does sound like you could improve the terminal client setup you're on. – Steven Lu Aug 13 '13 at 15:00

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.