What really happens when you type `ls -l *.c` in the shell?
Published on August 25, 2021
By: Selam Ayehubirhan
SHELL
Shell is an environment in which we can run our commands, programs, and shell scripts.
?It gathers input from you and executes programs based on that input. When a program finish executing, it displays that program's output.
It is a program that takes commands from the keyboard and gives them to the operating system to perform. It is a command interpreter between the user and the computer. It presents a command line interface which allows you to control your computer using commands entered with the keyboard.
The `ls’?command
?The?ls?command is used to list the contents of a directory.
?The?ls?command can be used in a number of ways, one of which is by using the option?-l.
If we use the?-l?option with?ls, we would be listing the contents of a directory in a long format.
The long format shows;
领英推荐
·????????The name of the files and subdirectories in the working directory.
·????????The last time the file was modified.
·????????The size of the file in bytes.
·????????The name of the group that has file permissions.
·????????The name of the user who owns the file.
·????????A representation of the file’s access permissions.
?Wildcards
The shell uses special characters that makes them powerful, these special characters are known as wildcards. Wildcards allow you to select file names based on patterns of characters, one of these wildcards is the asterisks (*).
“*” can be used as an argument to match any character. Using wildcards, we can construct selection criteria for filenames.
*?matches all filenames
*.c?matches all filenames that end with the characters?.c
What then happens when we type?ls -l *.c?and hit Enter in a shell?
?The command?ls -l *.c?from all what we have learnt and as seen above, lists all files ending with?.c?in the current working directory in a long format.