What happens when we types in ls -l*.c in the shell terminal?
First of all, we need to know what is a shell, a shell is the command interpreter between the user and the computer, when you write a command on the terminal, the shell translates the message to the computer and then the command is executed.
So what happens when you type ls *.c?
The ls command tells the program to list all files and directories in the current working directory. In this input however, there is a wildcard that is implemented before the ‘.c’. The wildcard is symbolized by the asterisk. The asterisk wildcard matches the characters that are placed after it, and tells the program to look for files that match those same characters. When one places an asterisk before ‘.c’ like in this example, you are telling the program to only list files that end with a ‘.c’.
So what happens when you type ls -l *.c?
To understand this command line, you need to split it.
First, we have ‘ls’, which is the command for listing files. ‘ls’ display all the files and directories located in the directory or folder that you indicates. If you don’t indicate a folder, ‘ls’ will list the files and folders of the current directory.
then, we have “-l ” Displays permissions, links, owner, group, size, time, name.
The output from “ls –l” summarizes the most important information about the file on a single line. If the specified pathname is a directory, ls displays information about every file in that directory (one file per line). It precedes this list with a status line that indicates the total number of file system blocks occupied by files in the directory (in 512-byte chunks or 1024-bytes if –k option is used). Following is a sample of the output along with an explanation:
Then, we have ‘*’, that is the character that represents all the files of a location. ‘.c’ is part of the name of a file or multiple files, so the combination of ‘*.c’ represents all the files with a name finished in ‘.c’. For example, if the order of characters where ‘c*’, the combination would represent all the files started with c and finished with something else.
So, the result of type and run ‘ls -l*.c’ in the shell prompt is a list of all the files in the current directory with a name finished in ‘.c’.