3 ms·
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 numb
by antongribok 3y 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.
- ComputerGuru 3y agoIt would help to explain what it does! -U: do not sort; list entries in directory order
- l0b0 3y agoIf 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.