In this post we will see basic of the command “ls” and what happens if we put “ls *.c”, but before we do thiswe have to know what the “ls” command is and what it’s for:
What is ls command?:
The “ls” command is a program of the shell he will show a directory contents on a list.
How ls command works?:
The “ls” command can be executed only typing “ls” on terminal generating as a result the display of files and directories ofthe current path on a list.
In the previous image we can see that when we put the command “ls” all the existing files in the example folder are listed.
the “ls” command has a certain number of parameters to change the result of the list, the most common are :
ls -l
use a long listing format.ls -a
do not ignore entries starting with “.” (show the hidden files).ls -R
list subdirectories recursively.
There are many more (see more), but I think these are the most significant, taking into the above, if we want to list the files in a long way and taking into the hidden files, What should we do?.
as we can see, adding the “a” and “l” parameters to the “ls” command will list the files long and show the hidden files.
Taking into this important information we can we can now explain the question at the beginning
What do the command “ls *.c” ?:
Now that we know what the “ls” command does, we need to know what “*.c” is for.
the *
means all, so if we put something in front of the *
in the following way “n*” means that any file containing an “n” character at the beginning will be listed:
Similarly, if we put something after the *
it means that any file containing an “n” character at the end will be listed:
So the structure of the command “ls *.c” it means that anything ending in .c will be listed:
Finally we can vary the previous command and any other with the parameters seen before at the beginning of the blog.
I hope this information has been to the liking of all the viewers, and RTFM :)