What happens when we use the ls *.c command?
Well, first of all, we must know the ls command and what it is for. We don't want to get ahead of ourselves, right?
ls
the ls command by itself works to list the files we have in the current working directory, we will see an example below:
As you can see, when I type ls on my console, the ls command lists all the files that were in my current working directory. Since we are clear what the ls command is for, let's continue
the digit * is used to specify that the command will take all file names that start with any character, let's see some examples:
g*
this specifies that all file names beginning with the character "g" will be taken.
In case it's still not clear, let's look at another example:
*b
in this case, all filenames ending with the letter "b" will be taken
So, "*" serves to specify to the console which characters to take, then in the case of the command we want to learn "*" helps us specify to the ls command which file names to list
ls *.c
As we can see in the image, when using "ls *.c" the command only lists the file names that end in ".c" and ignores all others.
Hope this helped you understand how the ls command works together with "*.c"
Software Developer
4 年No matter how long I've been using it, I always find new ways to use it.