2
#!/etc/bash
test_word=' ' # test_word includes only one space
if [[ ${test_word} =~ ^\s*$ ]]; then
echo "detect"
else
echo "not detect"
fi
結果檢測到空字符串和空白字符串是
not detect
它不工作。 請讓我知道如何檢測它。 還是請讓我知道像
if [[ -z ${var} ]]