What happens when you type ls *.c in the terminal?
‘ls’ is one of the most common and useful commands in linux. ‘ls’ is short for list, in keeping with the grand linux tradition of shortening every command name. You should also note that any basic command in terminal must be followed by the enter key. So what does ‘ls’ do? If you type it in a terminal and hit enter, it shows you all the files and folders in your current directory. You know how when you open your Documents folder on your Mac or Windows PC, you see an array of folders and files? It’s like that, but all in text. You use ls all the time while navigating through your files via the terminal.
How about the *.c bit? That’s trickier. Imagine you have 7000 files in your Documents folder, but only care about the files written in the C programming language. 7000 files is a lot to navigate through, yes? Luckily for you, any proper C program ends with the suffix “.c”. One of linux’s many powerful features is the wildcard character (*), which acts as a stand-in for any normal text. “*.c” translates to “any normal text ending with .c -” file.c, program.c, iLikeHolbertonSchool.c, and so on. Normally ls will list every single file in your current location, but “ls *.c” will list only the files that end with .c. Very handy for file navigation!