Do you c what I c?

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!

--

--

--

Software engineering student and lover of mountains.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Exploration of various options on eSpeak-NG

What have I been up to?

Raise your hand if you want to quit drinking coffee. Why, though???

Putting customers first with SLIs and SLOs (Part 2)

A collection of Google SQL coding interview questions

A collection of Google SQL coding interview questions by sqlpad.io

Number Systems

CS371p Fall 2020: Kelvin Yu

Evolution data to the cloud technology

The on-premises database — creating reports and visualizations from a SQL Server database.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Aleia DeVore

Aleia DeVore

Software engineering student and lover of mountains.

More from Medium

Bash for Beginners Part 6: Common expansions

LINUX LOOPS

Incrementing And Decrementing In Bash With Prefix And Postfix Operators

Five useful Linux commands