9

If I have a directory containing hundreds of files, using ls, ls-l, or dir gives me a list that's too long for the command terminal screen, so I'm unable to see most of the files in the directory.

I recall there being some argument for ls that allows one to scroll through the list in short increments, but can't seem to find it.

3 Answers 3

10

One option is to pipe the output to less or more

ls | less

or

ls | more
1
  • You can make a function of this so you can pass various ls options: ll() { ls "$@" | less; } Nov 30, 2012 at 22:52
1

Try doing this in a :

ls -1 | less
1
  • 1
    ls will automatically print a single column when it's stdout is a pipe, so you don't need the -1 Nov 30, 2012 at 22:47
0

One more way is to redirect the output of ls into a temporary file and then view that file with any editor of your choice - that way you can do searches etc. as well:

ls > res.tmp
vim res.tmp
emacs res.tmp
gedit res.tmp
grep "pattern" res.tmp
1
  • 1
    ls > tes.tmp && wine word.exe res.tmp (just kidding) Nov 30, 2012 at 18:36

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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