What on earth is , ls *.c ??

Diego Lopez
3 min readSep 15, 2020

Perhaps you are familiar with the terminal in your computer, perhaps you have heard about what shell or bash are, perhaps not.

But I’m here to explain a bit more about them and what exactly the command “ls *.c” is.

The terminal is an emulation of a command window where u can see and interact with the command line and in most GNU/Linux operating systems use the shell bash as the command language interpreter.

Now there are various commands we can use in this environment, although I’m not going to explain all of them in this blog, I will explain what the command ls is and what it does.

The first page of the command’s manual shows that this command lists the directory’s contents. Below we have written the command ls while being on the directory Dir0

As you can see we have a list of all files and directories in the current directory Dir0.

Now, there are certain options and arguments we can pass onto the command to ask specific questions, for example we can ask the command to show only file0 as follows.

If we write the name of the filewe want after ls we can show only that file.

With that in mind, we can ask the command more complex questions with what are called wildcards, say we want to find all the entries of the list that start with Sub, we would ask the command the following question.

If we write Sub* after the command it shows the 3 items of the list starting with with the letters Sub, by adding the asterisk (*) after Sub we ask the question what are the entries of the list starting with Sub and followed by any character possible.

So you may see where I’m going now, and possibly already know what the command ls *.c does.

So if we want to find all entries of the list ending in the characters .c we would ask the following question.

Now you see we can search for the entries of the list ending in .c by using the command ls *.c

With all this I hope you’ve learnt a bit about what a terminal is and what the command ls does, what wildcards are and how to search for any file or directory.

--

--