I was curious how many images I’ve managed to collect on my gifs site, so I ran a search on how to count the number of files in a directory. The result—unsurprisingly on the Unix Stack Exchance—was very simple:
ls | wc -l. You take the results of
ls (to list the directory contents) and pipe them to
wc (which gives line, word, and byte counts for whatever data is provided) with the
-l parameter (which returns only the number of new lines). I’d never used the
wc command before so that’s a new tool in my belt. Handy!
The number of gifs, by the way? 921, as of this post.