Idelahoz
2 min readJun 9, 2020

--

What happens when you type ls *.c

To know what the ls * .c command does, we must first know what the ls command is.

The ls command lists the content and optional information for directories and files. When you run the ls command with no options, it lists the files contained in the current directory, sorting them alphabetically.

It is also very important to know what the character * is used for. As you recall from our work with wildcards, the “*” character means match any characters in a filename, but what we didn’t see in our original discussion was how the shell does that. The simple answer is that the shell expands the “*” into something else (in this instance, the names of the files in the current working directory) before the echo command is executed.

Now, to the question at hand, What happens when you type ls *.c

Given the above concepts, we can conclude that the ls * .c command is used to list all the files in the current directory that have the ending .c

--

--