Find the number of files in a directory (Linux)

This article will show you how to find the number of files (including directories) within the current directory under Linux.

Command

ls -1 | wc -l

Syntax Breakdown

ls is the Linux command to list all files and folders in the current directory
-1 will list each file on a separate line
wc -l will count the number of lines returned from the ls -1 command (i.e. the number of files)


Please post your comments/suggestions!