What happens when you type ls *.c?

Deyber Castañeda
2 min readJun 11, 2020

If you are starting to use Linux or Unix-like operating sistems maybe you want to know what are the things that you have in your machine.
The terminal allow us to know that through a command and their options,
This command is ls
This list the content of the current directory. Some options of this command are the following.
-l Show the content in long format
-a This allow us to see the hidden files

Like these are a lot of option to list the content of directory.

Also there is a concept that is nessesary to undestand the answer to the tittle of this publication and are the wilcard characteres.

Wildcard characters:
The three main wildcard characters are,

Star or Asterisk (*)
Question mark (?)
Square brackets ([])
Asterisk (*) is used to search for particular character(s) for zero or more times. Question mark (?) is used to search for a fixed number of characters where each question mark (?) indicates each character. Square brackets are used to match with the characters of a defined range or a group of characters.

So, If we combine the ls command with the * wildcard character we will have an excellent way to list the files or directories that have a .c extension.
In this case this extension means that the file is a c program.

I hope that you get undestand what does the ls *.c command and you can apply it in your projects. Good luck.

--

--

Deyber Castañeda

Software Developer and Science lover always learning.