The files will be found in the path: /bin/ls and /bin/grepĤ) SHELL GLOBBING: It's a common mistake that the ls command will search for the files with the *foo pattern, however, this is a task of the shell. To check if the file exists, Linux will use stat(2) system call. Note: The 2nd argument is not *foo, we will see bash globbing later.ģ) SEARCHING FOR COMMAND: Bash will search the commands in the bash built-in commands, alias, and every directory in the PATH environment variable. Shell will divide the input into two processes with their corresponding argument. If you typed the following: ~]$ ls -l *foo | grep bar Let's assume that you are in the Linux terminal console, by example Bash.ġ) TYPING: First the shell console it's waiting for you to type a character, the stdin will read(2) the character save it into a buffer and write(2) the character back to the console, so you will see what are you typing.Ģ) PRESSING ENTER: When you press Enter key, the console will process the buffer, separate the command and parameters, this is called tokenize the input, but it's not part of this article neither. The commands that We are going to run are: " ls *foo | grep bar ". We are going to divide the explanation by process starting for the shell and the type of operation performed. Second I wrote this article as a personal note for what I'm learning but also because has been difficult for me find a straight forward answer about what occurs with a simple command like this. For now, I'll leave the details about bash or shell or the same ls, just to focus on whats happens at the Linux kernel level. I want to clarify two things: First, it's very difficult to go deep in every detail and probably I'm going to complete this article more and more over time. A lot of things happen, more than We are going to see here, but this article can give you an idea about whats occurs on Linux under the hood when you type the ls command.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |