What happens when you type ls *.c
When we’re working in console or terminal (OS Linux or Unix-Like) it’s almost necessary to input a command to list files, the command is “ls”. it is an alias (used to rename commands) of list sort. But, what it’s for?.
“ls” - is a Linux shell command that serves us to display files or directories contained in the current directory. let’s see the example below.
So far, we have seen how it works “ls” command in Linux. Now, we’ll see what it’s for *.c
— * - (Globs) it provides special characters to help you rapidly specify groups of filenames. These special characters are called wildcards. The wildcards allow you to select filenames based on patterns of characters. in few words it matches any string specified.
— .c - is a file’s extension in this case at the programming language C.
Now, let’s suppose what we have a lot of files as in the first one image, but we only we want to see the files ended in .c, so we use the command ls *.c.
We suppose that the files enlisted in the image below only we want to display the files ended in .sh
then, you must write ls *.sh and it just will display those files.
Well, now you know what happens when your write ls *.c in your shell prompt.