What happens when you type ls *.c
First at all, let’s see what ls command do.
If you type in your terminal the code <man ls>, you can see the man for the command
ls is a very useful command to list directory contents and has many options which allow us to list these contents in different ways like sort by rows or columns, see their size, list subdirectories recursively…etc ( man ls)
Everytime we type a command line and press enter, bash performs several processes upon the text before it carries out our command, these processes are called expansion.Then, for the shell, the character “*” means: match any character. This special character is called wildcard and there are another wildcards with which we can construct sophisticated selection criteria for filenames, combining patterns with some of these (Wildcards).
In this case, we are matching for files ending wiht “.c” in the current directory as we can see:
Combining wildcards and commands is a powerful selection criteria for manipulate our files. You should try it!