First, we will not introduce what shell scripts are. This blog only records every step of learning shell scripts.
First, we will introduce the basic shell rules:
The shell script is not a complex program. It is explained by line. The first line of the script is always #! It starts with/bin/sh and notifies the Shell programs below the system to use the Bourne shell on the system for explanation. Write the script name in the second line of comment, and the third line of Comment begins to write the script function-habit. The VI editor is generally used to compile shell scripts.
Next we will officially enter the first step of our shell programming:
Enter
sudo vi showhello.sh
To edit the script. Please query (click to open the link ).
Next, enter the following content into VI and enter WQ in the last line mode! Save and exit,
#!/bin/sh#ShowHello.sh#To show hello to somebodyecho -n“Enter Your Name:”read NAMEecho “Hello,$NAME!”
Then, add the executable permission to the script file:
chmod u+x showhello.sh
The script file is finally executed.
source showhello.sh sudo ./showhello.sh
The path to shell script self-learning-opening the door, a brief introduction and use