Hacker News new | ask | show | jobs
by antongribok 865 days ago
In case you ever have to work with a directory that has lots of files in it, sometimes it's useful to remember the -U flag in ls. For example to count the number of files, I sometimes use this:

  ls -U1 |wc -l
Can be very fast with lots of files on a modern Linux box.
2 comments

It would help to explain what it does!

    -U: do not sort; list entries in directory order
If you have GNU find,

  find . -mindepth 1 -maxdepth 1 -printf x | wc -c
performs about the same and includes dotfiles (not "." or "..", though) in the count.