There are 6 main types of conditional judgments:
[Email protected] test]# Ls-ltotal 8drwxr-xr-x 2 root root 4096 Jan 19:28 shell-rw-r--r--1 root root 4 Jan 17 19 : Test.sh[[email protected] test]# [-D test.sh] && echo "Yes" | | echo "No" no[[email protected] test]# [-F test.sh] && echo "Yes" | | echo "No" yes[[email protected] test]# [-e test.sh] && echo "Yes" | | echo "No" yes[[email protected] test]#
[[email protected] test]# a=10[[email protected] test]# b=20[[email protected] test]# [$a-eq $b ] && echo "y Es "| | echo "No" no[[email protected] test]# [$a-ne $b ] && echo "Yes" | | echo "No" yes[[email protected] test]# [$a -GT $b ] && echo "Yes" | | echo "No" no[[email protected] test]# [$a-lt $b ] && echo "Yes" | | echo "No" yes[[email protected] test]# [$a -ge $b ] && echo "Yes" | | echo "No" no[[email protected] test]# [$a-le $b ] && echo "Yes" | | echo "NO" yes
Shell Programming-Conditional judgment