Simple question I'm sure. I've seen an answer that show how to do it including subdirectories, but I want to know how many files (not folders) are in the current directory only. Thanks.
echo "Directory $(pwd) has $(ls -F |grep -v / | wc -l) files"
Bellow is an example result of my
Directory /data has 580569 file(s).
And bellow are my explanations:
echo double-quoted-messagewill print a desirable message.
$(any-desirable-valid-command)inside the double quoted message of an
echowill print the result of related command execution.
pwdwill print the current directory.
ls -Fis for listing all files and append indicator (one of */=>@|) to entries. I copied this from thom's answer.
grep -v /is a command for searching plain-text, the
-v /parameter will keep all the strings that do not contain slash(es).
wc -lwill print line counting.
I know this question is 3 years old, I just can't hold my urge to add another answer.