A detail about the code format written by shell scripts
As a beginner in shell script writing, the format is not very clear. Today I wrote a script to practice writing and found some problems, as shown below:
An input variable YES_OR_NO is defined,
According to the rule defined by the script, if the value is yes, the output is,
You input: yes
U r a sea man! Welcome you!
If the value is no, the value is
You input no
U r not a sea man, please exit this system
However, after the script is compiled, grant the executable permission to the script and compile it.
Enter the result "yes" after execution.
The screen output result is as follows:
If no expected result is obtained, an error is returned in row 4th. Considering the possible format of the condition, separate the variables before and after the condition with a space as follows:
After compilation and execution
Yes
Enter no to test
The returned value is the value of yes.
Finally, change the condition format:
Input no. The output result is:
Input yes, and the output result is
Done!
This example shows that the spacing between various variables, constants, and descriptions, and the overall format of the shell script are sometimes very exquisite. If you do not pay attention to it, it may affect the running of the program, this causes unnecessary Error Correction overhead.
All the codes in the following example are similar. Sorry!