Server Fault is a question and answer site for system and network administrators. 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

It seems that under most situations ls will read the whole directory before producing any output - typically because it needs to sort or columnise the output. Normally this is fine but when reading a very large directory from a slow network server this effectively causes ls to hang.

Is there a way to get ls to print partial output as it goes along? I've tried the following, on Mac OS X 10.6.8, but they do not appear to work:

  • ls -lf
  • ls -1f

Just in case what I want is not clear, the following Perl script does roughly the right thing:

opendir(DIR, ".") or die "can't opendir $dir: $!";
while($filename = readdir DIR) {
    print $filename, "\n";
closedir DIR;

... only I'd like to be able to use -l, -lO, and not have to write it myself!

share|improve this question
The particular scenario in which the need for this arises is trying to ls the bands/ subdirectory of a large .sparsebundle that resides on a slow Drobo FS. – cpcallen Apr 22 '13 at 14:45
As an alternative, you can try the find command with the -ls option or even -exec ls -lf {} \; – Safado Apr 22 '13 at 15:00

You're on the right track with the -f option, which prevents sorting of the output, but the man page notes that with -l,

If the output is to a terminal, a total sum for all the file sizes is output on a line before the long listing.

You may be able to prevent this summation (which would require stating all the files in the directory first) by piping the output to cat, to prevent outputting to a terminal.

I don't know why the -1f form is not working for you; it seems to work fine for me on GNU ls. Another quirk of GNU ls (that may not apply to you) is that -lf is the same as -f, but -fl is a combination of -f and -l (long, unsorted listing). Try switching the order of some of your flags to be sure this is not a problem for you.

share|improve this answer

Have you tried find?


find . -ls
share|improve this answer

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.