Shell script learning notes-introduction and basic format shell introduction shell the original English meaning is shell, shell meaning. In linux, the shell in unix is a command line interface that accepts user commands. When the shell executes the program, it requests the kernel to start a new process and execute the current sequence in the process. The specific implementation is that the shell calls the fork function to generate a new process, in the new process, call the exec function to load the specified program. Shell can execute binary executable files (elf files) or script files (with executable permissions ). For processing script files, shell starts a new shell. The basic format of shell scripts is because there are many shell implementations. The default shell used in linux is bash, but there are many other shells, such as B shell and c shell. Therefore, when writing shell scripts, we need a mechanism to inform the kernel about which shell we need to execute our scripts. The shell script uses the first line in the script to identify which shell to use. [Html] #! /Bin/bash all shell scripts start with one line above. Script #! At the beginning, the complete path of the interpreter is followed by parameters. The kernel will call the interpreter according to the corresponding parameters. We compile a simple script program nusers. sh, which shows the number of users currently logged on to the system. [Html] #! /Bin/bash who | wc-l who command prints information about the currently logged-on user, and transmits the result to the wc program for processing through pipelines, wc-l prints the number of lines output by the who command (the who command displays the information of each user in one row), that is, the number of users.