001、
[b20223040323@admin1 test2]$ ls test.sh [b20223040323@admin1 test2]$ cat test.sh ## 测试脚本 #!/bin/bash a="abc" b="abc" if [ $a == $b ] then echo "identical" else echo "different" fi [b20223040323@admin1 test2]$ bash test.sh ## 执行程序 identical
002、
[b20223040323@admin1 test2]$ ls test.sh [b20223040323@admin1 test2]$ cat test.sh #!/bin/bash a="abc" b="xbc" if [ $a == $b ] then echo "identical" else echo "different" fi [b20223040323@admin1 test2]$ bash test.sh different
003、
[b20223040323@admin1 test2]$ ls test.sh [b20223040323@admin1 test2]$ cat test.sh ## 测试脚本呢 #!/bin/bash a=$(seq 10 | md5sum) b=$(seq 10 | md5sum) if [[ $a == $b ]] ## 这里加双重中括号的原因是变量a和b中有空格 then echo "identical" else echo "different" fi [b20223040323@admin1 test2]$ bash test.sh ## 执行程序 identical
标签:test2,相同,echo,admin1,test,sh,b20223040323,linux,字符串 From: https://www.cnblogs.com/liujiaxin2018/p/16833339.html