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

Background Syncing — how to never miss any local change

Soft Skills Every Programmer or Data Scientist Should Master

Initial Tools & Languages Needed Before Becoming a Web Developer

App Shortcuts and Maskable Icons: Play It Like Twitter

nevernude: Automatically cut out NSFW nudity from videos using Machine Box + ffmpeg

Why I transitioned from jazz guitarist to web developer

How to get out of the newbie developer black hole

This article records a few the of best websites to learn and apply your coding skills and…

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: Audie Bethea

CS373 Spring 2022: An Vi Nguyen

CS373 SPRING 2022: John Mackie