What happens when you type ls *.c in your shell ?
History
The “ls” command, abbreviation of “list”, allows you to list the contents of a directory, appeared in Multics, the ancestor of Unix, in which it will be preserved, with the years options like “-l” and many others will be added, other implementations will emerge with BSD or even GNU.
Usage
By default the command will give you a simple list of your files and folders.
By adding the following parameters you can list the contents of the directory with more information such as file and folder permissions, groups, creation date, size, etc…
You can also add the following settings to list and display hidden files and folders.
ls *.c ?
This is all very nice, but what does this famous command do?
The following syntax allows you to display all files ending with a “.c”, often on the command line the star means “all”
Ok but that’s not enough I need to understand how my computer does it, is it black magic? homeopathy?
When you type the ls *.c command in a terminal, the shell first interprets the *.c pattern by searching for all files in the current directory whose names end in .c. This step, called pattern expansion, transforms the command into an explicit list of files, e.g. ls file1.c file2.c file3.c. Next, the ls program is executed with this list of files as arguments. c file2.c file3.c. Next, the ls program is executed with this list of files as arguments. ls reads the necessary information on each of these files, such as their name, size, permissions and modification date, then displays them in formatted form in the terminal. This gives you a clear view of the C source files in the directory.