Count the number of files in a folder with wc
$ ls | wc -l
will display the number of files in the current directory (folder).
$ ls *.md | wc -l
will display the number of Markdown files in the current directory.
In these two examples, we use
ls to list the content of the directory and then pipe (i.e.
|) the output of
ls to the command
wc which will display number of lines as we invoke the option
-l, short for
In the second example we tell
ls to only list Markdown files using a wildcard (i.e.
*) and the extension of Markdown files (i.e.
To learn about
$ man wc.