How to count number of files in a directory but not recursively
ls -F |grep -v / | wc -l
ls -F
list all files and append indicator (one of */=>@|) to entriesgrep -v /
keep all de strings that do not contain a slashwc -l
count lines
Try this oneliner:
find -maxdepth 1 -type f | wc -l
Try this
ls -al | grep ^[-] | wc -l
ls -al
-- list all file with long listing formatgrep ^[-]
-- search for string which start with "-" that is symbol for denote regular file when list file with ls -alwc -l
-- count lines