¿What happens when you type <ls *.c>?

Adrian Felipe Vides Jimenez
2 min readSep 16, 2020

Hey, welcome.
We have this little exercise today, and It is, what happens if you type in your shell the next command:

ls *.c

¿What will it display?
So to answer this question, first we need to understand what we are typing.

Command <ls>

ls command is used to display a list of the files and directories that are in the current directory. Let’s see an example:

ls file_1 file_2 fil_0.c fil_1.c
typing <ls>

As you can see in the current directory are 6 files and 2 directories.

Now let´s move on

Now you just want to list the files whit a specific extension, and to do that you will need to use an asterisk (*). That is useful to match an extension, in this case <.c>. So observe the next image:

ls *.c
typing <ls .*c>

As you can see in the first case It is typed <ls> and it displays all files in the working directory, but in the second case <ls *.c> it matches the files with the extension .c and displayed them.

¡And there you go!

Now you know how to display a specific group of files, I recommend you to keep reading and studying so you may learn even more stuff about this and other commands

--

--

Adrian Felipe Vides Jimenez
Adrian Felipe Vides Jimenez

Written by Adrian Felipe Vides Jimenez

I'm a Software Developer passionate by programming, videogames and music. Nowadays studying at Holberton School