What happens when you type ls *.c

Linux ls command permit us displaying a list of the files and directories (folders) that are contained in a directory; if no directory is specified, the command will assume that we want the list of all the contents of the current directory. That is what happens when you write ls:

But… what to do if we only want to list files of a certain type? This is where the * comes into action. The asterisk is a character that will match any number of characters in a file name:

ls *c

If you add an extension, you will be able to visualize only the files of that type. For example, this would happen if you wanted to see only the files ending in .c, regardless of the characters that appear before the extension.

As you can see, ls * .c lists all files in the current directory with extension .c



Love podcasts or audiobooks? Learn on the go with our new app.

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