What happens when you type ls *.c

More screens != better programming

The gist

To start to explain what we get when we input this command, lets ask what we’re trying to achieve. If you’re trying to list all files ending in .c, you’re in luck! We start up our terminal, fire up an ssh and we’re off!

But how exactly are we going about this? Well, for starters, we’re using the ls command. This command, called list, does just that; it makes a list of any files you want. To do so we simply type in the letters ls in a terminal and press enter. But in this case that’s not good enough, we want more, we want specific results, we want to see all files that end in .c so what could we add to help us search for every file that meets a certain criteria? In comes the second, weirder part of our script: the wildcard.

Wildcard (or *) is a command that quite simply represents all of something. It is an expansion. When combined to an extension, for example .c, we are saying “Hey computer, show me everything that matches this thing I’m looking for [.c]. The computer takes your input, does computery things and out comes a list of every file that matches your query. Congrats!

The computery things

Let’s dive deeper. How exactly does an input of arbitrary characters such as ls and * turn into a readable, intuitive result? The answer is through un-intuitive, low-level means.

First, an alias expansion occurs. What this means is that the computer searches for any aliases (i.e. commands hiding behind different names), and if it finds one it’ll search deeper for more aliases. Once it reaches it’s conclusion it moves on to the meat and potatoes: commands. It will find our desired command, in this case ls, perform it and return a result (output).




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

Recommended from Medium

Flutter for Mobile Applications

Frequently used Active Support Methods in Ruby on Rails — Part 2

What, how and when to automate

Python Matplotlib Basic Notes

IPFS 101 Pt 2: Application Introduction

Without a Commute to Work, I Am Using That Time to Improve Myself

Adding laser attacks to our boss

Symfonos:3 vulnhub VM

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
Gabriel Vazquez

Gabriel Vazquez

More from Medium

CS373 Spring 2022: Sabeer Shahzad Week 9

Trails in ruby rails- convention over configuration!

Compare & Contrast (Full)

Savitch’s Theorem