Learning Shell : What hapens when you type ‘ls *.c’ in your shell

Screenshot taken from the comand line

When you first type the ls command it will list all the files in the current directory, awesome right?!, if you actually want to go a bit further and do a specific search in your current directory then ‘ls *.c’ command will print on your terminal all the files that end with with ‘type.c’ in your current directory, it becomes very handy when you need to search and sort files in your current directory to speed up the process of searching.

In case you were wondering the reason why the ‘ls *.c’ command has an ‘*’, well, the ‘*’ in the Linux command line is a wildcard expansion and tells the operating system to find all of the certain criteria, and promoting it with any other file extension it will do the same magic: ‘ls *.js’ (javascript files), ‘ls *.py’ (python files), ‘ls *.jpg’ (pictures with jpg extension).

To simplify the mentioned above, this command ‘ls *.c’ will sort the files the way you want by specifying the extension file, and it will make your work on the shell faster!.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store