linux test使用, 比较数字、字符串、文件

详情参考:

http://blog.itpub.net/23655288/viewspace-734316/

自己的代码: 


if [ "SPC103T" \< "SPC104" ]; then
        echo " into if"

else
        echo "into else"

fi

结果输出:

into if

#! /bin/bash

ne_patch_ver=$1

tt_cpatch_ver=""
for tmpver in $(ls -rd */ | grep SPC)
do
        if [ "${tmpver}" = "${ne_patch_ver}/" ] || [ ${tmpver} \< ${ne_patch_ver} ]; then
                tt_cpatch_ver=${tmpver}
                echo ${tt_cpatch_ver}
                break

        fi
done

多个test条件

https://www.cnblogs.com/jjzd/p/6397495.html

||与 [  ]之间可以有空格也可以没有


 

猜你喜欢

转载自blog.csdn.net/u013985241/article/details/82995531