Do you c what I c?

Aleia DeVore
2 min readSep 15, 2020
A deck of cards is spread across a table. On top, an ace of spades is visible.
Photo by Jack Hamilton on Unsplash

What do you do when you only want to see the c files in your directory? With a simple string, you can filter only the desired files to your list.

ls *.c

How does this command work? Let’s start at the beginning of the string.

ls

The ls command lists directory contents. When used alone, it will display the names of all contents that are not hidden (starting with a period).

“*”

The * acts as a wildcard, instructing the command to match certain patterns. When used on its own, an asterisk will select every item in the current directory. However, it can also select only specific characters.

An asterisk at the end of a string will select only items beginning with that string. For example, selectthis* will select only items beginning with selectthis.

Inversely, an asterisk at the beginning of a string will select only items ending in that string. For example, *file will select only items ending with file.

.c

When we pair the * wildcard with .c, we tell the command line to select only items ending in .c. As a result, the ls command will filter the list of items in the directory down to only c files.

Pair this string with other ls selectors to sort the c files to your specification!

--

--

Aleia DeVore

Software engineering student and lover of mountains.