Requirement description :
Today, I helped a colleague adjust the script, which involves judging that a string is not empty, and record it here.
Operation process :
Use -n to determine whether the string is not empty, if it is not empty then it is true
#!/bin/bash Str1='MyTest' if [[ -n $Str1 ]];then echo "$Str1 is not empty." fi
Execution result :
[am@hadoop3 scripts]$ sh test.sh MyTest is not empty.
Note: After testing, the string is not empty, the judgment is true.
Document Creation Time: April 26, 2018 16:27:34