What Does This “ls *.c” Do?

The picture above is composed of three lines. The first: bash-3.2$ prompts the user for an input. The user types in ls *.c to display all of the contents of the current directory. The result: 1.c 2.c 3.c 4.c is a list of all the files with a name ending in .c
So what happened here? What’s really going on here?
The image above is a screenshot from the application “Terminal” on Mac OSX. Terminal is an executable that interprets commands from Standard Input and executes those commands through the Bash shell. In plain words: through this text-based program, the user tells the computer to do something, and the computer does it. Every time a user opens up the program “Terminal,” Terminal opens up another program, called a command shell. For Mac and Linux operating systems, the program is called Bash (short for born-again shell.)
The first line: bash-3.2$ is called the command prompt. The application “Terminal” is prompting the user to type in some text, which is then interpreted by Bash as a call to run a program. The call to the program here is ls. A way to remember what the ls program does is by knowing it’s function. ls lists. When called, lslists all the files in the current directory. Just by itself, the ls program returns:

However, the command we want to know about is not ls; it is ls *.c The * is a symbol that represents “all files in the current working directory” and is a type of wildcard. Other wildcards are expanded into different things, which I will explain another time. The combination of the wildcard * and .c narrow down the results of the command. Now the ls *.c command is interpreted by Bash as: “list all files in the current working directory that end with .c” hence the result: 1.c 2.c 3.c 4.c