What happens when you type `ls -l *.c` in the shell ?
To begin with i'am expecting that you have a basic knowledge about shell scripting and linux command.
You have to understand what a shell is in relation to the kernel to understand what really happens when you run a command.
The Kernel is the most fundamental part of a computer operating system. It’s a program itself and it controls all other programs on the computer. It talks to hardware and software and is highly involved in resource management.
The Shell is an application that executes programs called commands through an interactive user interface with an operating system. It is the layer of programming that understands and executes the commands a user enters. In some systems, the shell is called a command interpreter.
SO WHAT DOES REALLY HAPPEN WHEN YOU TYPE ls *.c?
LS
Among the many shell commands at your disposal, ls remains among the most heavily used commands in shell. When you type man ls and hit enter, the manual page for the command ls appears, and it is here where you can learn all about the command.
领英推荐
Briefly talking from the description we know that ls displays information about the files in a certain directory (current directory by default).
Ls *.c
One of the available ls options is the “ls”, and this command has three parts. The first part is the “ls”, this part does what we see in the previous part “Ls Command”. Then, we have the “*” part, the symbol * in this case means all things in the current directory (all the files, and directories), and the last part is “.c”, in this case it means, everything that ends whit the characters “.c”.
We can see that if we type the command “ls *.c”, all files that ends with the .c format will show up.
CONCLUSION
The final result after the shell communicates with the kernel to run the ls command is output to the user displaying all files ending with the .c extension without the user even noticing the work involved in making this happen.
AUTHORS
This blog was made as part of the curriculum in HOLBERTON SCHOOL