What happens when you type ls *.c

First lets talk about ls command.

The ls command is super useful when we need to see the files and directories that we have in the directory that we are in.

Man ls

When you execute the ls command without options, it lists the files contained in the current directory, and sorting them alphabetically

ls command to list files and directories in my curent path

There are so many options to ls, and you can see them typing ls - -help in your console. Some of them are:

ls — help to see information about ls command

This options are so hepful when you need to list something in specific, and you dont know what the option is. For example ifyou need to find hidden directories, you could use de option a.

ls with a option.

Now, lets talk about “*”

Wildcards or regular expresions are used by Linux for character substitution or sequence of charater. These wildcards character can be very useful when we se the command to find a file, or several files or directories whose name contains a certain sequence of characters. “*” is a wildcard among many others.

The wildcard “*” references any character string in the file name. When the character “*” is used to refer to the name of a file, the command interpreter replaces it with all the possible combinations coming from the files in the directory to which we are referring.

Thereby, when you type ls *.c in your console, you are listing the files or directories that contains a .c extension at the end of their names, in the current directory.

Executing ls *.c

If you want to understand mor about the ls command and wildcards, you can visit the next urls:

Hi I am a financial engineer, and a software development student in Holberton School!