What happens when you type “ls *.c” into your shell?

Ojo Timilehin Joseph
1 min readMar 31, 2022

--

The first step is to know what ls means:

The ls command writes to standard output the contents of each specified Directory parameter or the name of each specified File parameter.

Now, each time you type a command line and press the enter key, bash performs several processes upon the text before it carries out your command, in this case, a list.

But what about the *.c?

The * matches any characters in a filename. When the enter key is pressed, the shell automatically expands any qualifying characters on the command line before the command is carried out.

The .c is a file extension. A file extension (or simply “extension”) is the suffix at the end of a filename that indicates what type of file it is. For example, in the filename “hello.c,” the .c is the file extension. (.c files are C programming language files)

So, by typing ls *.c on the command line, you will see all files with .c extension.

--

--

Ojo Timilehin Joseph
Ojo Timilehin Joseph

Written by Ojo Timilehin Joseph

Frontend Software Developer with experience in projects related to web development (HTML, CSS, Bootstrap, JavaScript), and App development (Node.js, React).

No responses yet