When assigning a value of "=" to a script variable, "=" cannot have spaces left or right, otherwise it will prompt an error.
For example, the following examples:
#!/bin/bashbegin_time = ' date +%h: %m:%s ". /a.outend_time = ' s ' echo ' " echo " $BEGIN _time " echo " " echo " $END _time
When the system time is assigned to Begin_time and Eng_time, in accordance with the previous habit, "=" Left and right to add a space, resulting in an error message:
[email protected] ~/documents $ ./get_time. SH . /get_time. SH 2 Command not found
Originally for bash scripts, when you assign a value with "=", no spaces can appear on either side of the "=". That
#!/bin/bashbegin_time = ' date +%h: %m:%s ". /a.outend_time = ' s ' echo ' " echo " $BEGIN _time " echo " " echo " $END _time
At this point, no error message appears. It can be seen that in bash, the use of spaces should be particularly cautious, or unexpected errors are likely to occur. Refer to the following articles for specific information:
Http://www.jb51.net/article/60328.htm
bash scripting using "=" assignment, left and right cannot leave spaces