Understanding the [ls *.c] Shell Command
If you're reading this, you are probably looking to find a more in-depth summary of the command [ls *.c], and you have come to the right place. It is a lot more simple than it looks and with a step by step breakdown it's very easy to understand even for Shell beginners. Let me explain:
Think of this command in two parts. The [ls] is short for list and actually lists out all directories or files depending on which directory you are in. If you type [ls] and hit [Enter] while you're in a certain directory, then you can see all executable and non-executable files (executable files will be green) in the folder. [ls] is extremely helpful and used often.
Now for the other half of this command: [*.c]. The asterisk, also known as "*" is called a wildcard in the world of coding. This character acknowledges the text on either side of it (example* or *example) and with the function [ls] prints a list of files or directories beginning or ending with whatever you are searching for specifically. For example, you have a long list of files but you're looking to find one that begins with a "j". All you have to do is type [ls j*], hit [Enter], and your command line will print every file that starts with a "j". If you wanted to find a file that ends with a "j" then the command is [ls *j]. These are very similar so make sure to keep your eyes on the asterisk!
Now with your new knowledge you will note that all together, [ls *.c] will print all files or directories that end with .c
You can do this as many times as needed and it doesn't change anything about your files. So, go ahead, and try it out! It may guide you to notice the files you don't need or maybe even help you see why your code isn't executing.