1.判断字符串为空 if [ -z "$str" ]; then echo "empty string" fi 2.判断文件是否存在 if [ -f /home/builder/.profile ]; then echo "File exists;" fi 3.逻辑非 if [ ! -f /home/builder/.bash_profile ]; then echo "here!"else echo "te
2021-09-01 1. 字符串判空主要用到两个参数 -z 判断字符串为空否 -n 判断字符串不为空 2. 实例 #!/bin/bash PID=`date` if [ -z "$PID" ]; then echo "PID is empty" else echo "PID is not empty" fi #!/bin/bash PID="test" if [ -n "$PID" ]; then ech