差别
这里会显示出您选择的修订版和当前版本之间的差别。
两侧同时换到之前的修订记录 前一修订版 后一修订版 | 前一修订版 | ||
blog:shell:03_shell_cond_and_branch [2022/08/26 11:04] – caodan | blog:shell:03_shell_cond_and_branch [2022/08/26 11:31] (当前版本) – caodan | ||
---|---|---|---|
行 17: | 行 17: | ||
2. 文件的判断 | 2. 文件的判断 | ||
- | | + | ``` |
- | [ -r file ] 用户可读为真 | + | [ -r file ] 用户可读为真 |
- | [ -w file ] 用户可写为真 | + | [ -w file ] 用户可写为真 |
- | [ -x file ] 用户可执行为真 | + | [ -x file ] 用户可执行为真 |
- | [ -f file ] 文件为正规文件为真 | + | [ -f file ] 文件为正规文件为真 |
- | [ -d file ] 文件为目录为真 ,即检测目录是否存在。 | + | [ -d file ] 文件为目录为真 ,即检测目录是否存在。 |
- | [ -c file ] 文件为字符设备文件为真 | + | [ -c file ] 文件为字符设备文件为真 |
- | [ -b file ] 文件为块设备文件为真 | + | [ -b file ] 文件为块设备文件为真 |
- | [ -s file ] 文件大小非0时为真 | + | [ -s file ] 文件大小非0时为真 |
- | [ -t file ] 当文件描述符(默认为1)指定的设备为终端时为真 | + | [ -t file ] 当文件描述符(默认为1)指定的设备为终端时为真 |
- | [ -e file ] 如果文件存在,则为真。 | + | [ -e file ] 如果文件存在,则为真。 |
- | [ -L file ] 如果文件为符号链接, 则为真。 | + | [ -L file ] 如果文件为符号链接, 则为真。 |
- | ``` | + | ``` |
3. 逻辑判断 | 3. 逻辑判断 | ||
- | | + | ``` |
- | [ condition -a condition ] 与 | + | [ condition -a condition ] 与 |
- | [ condition -o condition ] 或 | + | [ condition -o condition ] 或 |
- | [ condition ! condition ] 非 | + | [ condition ! condition ] 非 |
- | ``` | + | ``` |
4. 字符串判断 | 4. 字符串判断 |