我想通过 bash 脚本测试文件或目录是否存在:
if [ -f "$file" -o -d "$file" ]; then
# Do things
fi
Run Code Online (Sandbox Code Playgroud)
但此测试不适用于应用程序文件(.app),我在测试手册页上找不到答案,并且认为 .app 被视为 osx 上的文件夹。
检查目录是否存在:
if [ -d "$<app name>.app" ]; then
# Control will enter here if $<app name>.app exists.
fi
Run Code Online (Sandbox Code Playgroud)
检查目录是否不存在:
if [ ! -d "$<app name>.app" ]; then
# Control will enter here if $<app name>.app doesn't exist.
fi
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
11720 次 |
| 最近记录: |