I want to know the number of items (files, sub-directories etc) inside a particular directory.
There seems to be a lot of questions about it but most, if not all, answers seems to rely on
wc -l. For instance:
ls -1 | wc -l
But that will give the wrong answer if one or more files have new lines in their names. Another problem here is that
ls -1 might return more than just files.
A non portable answer was hidden inside the comments of one of the thousands similar questions. Works, but unfortunately it relies on
-printf which is not available in my distro.
find -maxdepth 1 -type f -printf "\n" | wc -l
Is there a more portable solution that can correctly handle files containing any char in their names?