Ethan Mayer Bloom
2 min readFeb 5, 2019

A Deeper Look Into The Command “ls *.c”

Week 2 of Holberton School, and today I was asked to write an article explaining the meaning of the command ls *.c .

Let’s break down this command piece by piece. First of all, what even is a command? Why do we need commands? The command line is an integral part of the Linux operating system, and as such it offers the user a possibility to perform tasks more efficiently, and with better precision.

To explain how the command ls works, we first have to understand how the system divides our files. Think of our files divided up like a tree; at the root of the tree comes the root directory, and underneath (or above in tree form) come more sub-directories. Each sub-directory contains files, or more sub-directories that follow the same pattern. This system helps divide the many files into categories, instead of having one big unorganized mess.

The ls command shows us the different files we have in the current directory. These files can be regular text files, executable files, or directories that lead to more files. ls stands for list, i.e., a list of files.

Sometimes, we need to look for specific file types, as the current directory can contain hundreds of different files. This is what the wildcard is for. Using the wildcard, we can display only the files we need. Wildcards are simply symbols (such as ‘*’ or ‘?’) that represent other characters. For example, a question mark symbol represents a single occurrence of a matching character. An asterisk (‘*’), represents one or more occurrences of any character, including no characters. Using these and other wildcards, we can represent file names that contain certain characters, or end/begin with certain characters. Let’s say we need to display all files that begin with the letter ‘t’. We know that the command ls displays all files in the current directory, so we can use the command combined with t* to show only these files. The final command is ls t*.

Now to our final command! ls displays the files in the current directory, that we know. * matches one or more occurrences of characters, and .c is the file extension. So ls *.c , would show all the files in our current directory that end with the extension .c .