if [ -z "$a" ] 这个表示当变量a的值为空时会怎么样 zero
if [ -n "$a" ] 表示当变量a的值不为空 not zero
if grep -q '123' 1.txt; then 表示如果1.txt中含有'123'的行时会怎么样
if [ ! -e file ]; then 表示文件不存在时会怎么样 取反
if (($a<1)); then …等同于 if [ $a -lt 1 ]; then…
[ ] 中不能使用<,>,==,!=,>=,<=这样的符号
#!/bin/bash
# grep结合if示例,如果root存在就输入存在
if grep -qw 'root' /etc/passwd #-q 参数,本意是 Quiet:不打印 -w精准匹配
then
echo "cunzai"
fi