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

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:

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:

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

--

--

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
Adrian Felipe Vides Jimenez

Adrian Felipe Vides Jimenez

1 Follower

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