Shell: What happens when you type ls *.c
first of all, let’s start by remembering concepts that are forgotten overtime to get to the main problem.
¿what is shell?
shell is a command interpreter, this means that the commands we write will be received by shell.here are some examples of shell types
bash, emacs, Windows command prompt, and more.
Now, knowing that it’s a shell, let’s talk about a command that is used in Linux.
“Linux is an operating system like windows is known to be open source”.
¿what does the ls command?
the ls command is very useful, is a command that you will use in your day to day in Linux to see the files and directories that we have within the directory in which we are. It shows us the files and directories inside the current directory, including hidden files and directories.
but then what did I mean by that?
Actually, the ls command is one of the most common commands you’ll find on Linux,
is a whole world, here an example of its syntax:
ls [OPTIONS] DIRECTORY
then we know what it does ls remember that we can use many ls arguments for specific tasks, let’s see the next part of our command.
¿what’s a wild card *?
A wildcard * what it will do in our terminal is to search a sequence of characters, in this example, we are going to combine the commands already learned ls and *, in this case, we are not going to specify a search simply we execute it to know that it prints us.
Here we can see that he pointed out all the files we have in the directory as if there was no wildcard, so he didn’t really do anything?.
What happened was we didn’t specify a search.
Now let’s do it with our command having what happens
Ready here we can see what was printed, but what about our other files?
what our command did was filter out our search
but then what are we looking for?
What we did was to list all the files with ls and with the wildcard filter our search so that we only see the files that end in .c
I hope you could understand what this command really does and how it can facilitate many things.