What happens with ls *.c?

Kathleen McKiernan
2 min readSep 16, 2019

--

Using the command ls *.c can be deceptively powerful. At a glance, one might read the list command and think it is a fairly pedestrian piece of code, but at a closer glance, there is far more than what meets the eye.

The ls command has the ability to retrieve almost any information that can be used to categorize and display content. Even without the use of an argument, it is vital for helping orient the user within their terminal. It becomes a roadmap of possibilities through an interconnected network of data.

When a wildcard is utilized, it can be a programmers best friend or their worst enemy. Using * has the ability to grab basically everything within a system. When paired with a filetype, such as .c, it retrieves every .c file it can. Once retrieved, it can be paired with a number of commands, such as rm, mv and of course ls. On thing to keep in mind is just how easy it is to make a big mistake when using a wildcard. It can be very difficult, if impossible, to undo a mistake made with a wildcard. When in doubt, checking the man page for ls could be beneficial to see if there is an argument that could work similarly.

--

--

Kathleen McKiernan
Kathleen McKiernan

Written by Kathleen McKiernan

Cosmetologist to Coder — Holberton School New Haven

No responses yet