August 1, 2023

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 --lines.

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. .md).

To learn about wc run $ man wc.

wc was first released in 19711. It is now part of the coreutils package which is copyleft-licensed and is maintained by Jim Meyering2


  1. wc’s first man page.↩︎

  2. Coreutils - GNU core utilities’s webpage.↩︎

✍✍✍✍✍✍✍✍✍✍✍✍✍✍

I do self-funded research and I'm writing a book.

> What's the book about?

About technologies and agency.

Meaning, technologies can foster agency. No doubt. But I am also asking:

Can usage of technologies give us a sense of empowerment while in fact undermining our abilities?

I posted a summary of the prologue on the homepage: https://yctct.com/

✍✍✍✍✍✍✍✍✍✍✍✍✍✍


personal computing command-line interface (cli) gnu linux trisquel shell literacy wc grep wiki office applications

No affiliate links, no analytics, no tracking, no cookies. This work © 2016-2024 by yctct.com is licensed under CC BY-ND 4.0 .   about me   contact me   all entries & tags   FAQ   GPG public key

GPG fingerprint: 2E0F FB60 7FEF 11D0 FB45 4DDC E979 E52A 7036 7A88