我正在修复一些我经常看到的旧bash脚本
if [[ -n $VARIABLE ]]; then
Run Code Online (Sandbox Code Playgroud)
语法我试图谷歌它,但可以找到为什么"-n"用于,以下是我所知道的
Comparisons:
-eq equal to
-ne not equal to
-lt less than
-le less than or equal to
-gt greater than
-ge greater than or equal to
Run Code Online (Sandbox Code Playgroud)
文件操作:
-s file exists and is not empty
-f file exists and is not a directory
-d directory exists
-x file is executable
-w file is writable
-r file is readable
Run Code Online (Sandbox Code Playgroud)
谁会让我知道-n做什么?
dev*_*ull 12
help test 会告诉你:
String operators:
....
-n STRING
STRING True if string is not empty.
Run Code Online (Sandbox Code Playgroud)