Shell Script pros and cons analysis
The shell uses external commands and some of the default tools of the bash shell, so it often calls an external library of functions, so the command cycle is less than the traditional programming language.
Therefore, Shell script is good for system Management , but it is slower when dealing with a large number of numerical computations .
Considerations for Shell Script writing
1. If one line is too much, you can use \[enter] to extend to the next line
2. # can be used as an annotation
How to execute Script
1, direct command execution (to have readable executable permissions)
Absolute path, relative path, variable path function (e.g. ~/bin/)
2. Execution in bash process
such as bash shell.sh, sh shell.sh, source shell.sh
The same as the usual, in the practice of learning
Echo-E"I'll use the ' touch ' command to create 3 files"Read-P"Please input your filename"Fileuserfilename=${fileuser:-"filename"}date1=$(Date--Date='2 days ago'+%y%m%d) Date2=$(Date--Date='1 days ago'+%y%m%d) Date3=$(Date+%y%m%d) File1=${filename}${date1}file2=${filename}${date2}file3=${filename}${date3}Touch "$file 1"Touch "$file 2"Touch "$file 3"
1. Basic usage of Read
2, date1=$ (date--date= ' 2 days ago ' +%y%m%d), use the command in $ () to get information
3. filename=${fileuser:-"filename"} involves "test and content substitution of variables"
Echo -e "youshould input 2 numbers, I'll cross them"" /c7> "" "Secondnumbertotal =$ (($firstNumber *$ Secondnumber))echo"\ n The result of $firstNumber X $secondNumber is ==> $total "
1, var=$ (Operation content)
#每日Linux小练习 #06 Shell Script Note Summary