linux-shell-if如何判断truefalse

linux-shell-if如何判断truefalse

2023年8月2日发(作者:)

linux-shell-if如何判断truefalse以查找⽂件为例:同级⽬录下存在find 不存在find1#!/bin/bashif test -e find;then echo "ok"

else echo "no"fiif [ -e find ];then echo "ok"

else echo "no"fiokok#!/bin/bashif test -e find1;then echo "ok"

else echo "no"fiif [ -e find1 ];then echo "ok"

else echo "no"finono#!/bin/bashtest -e findecho $?test -e find1echo $?[ -e find ]echo $?[ -e find1 ]echo $?0101结论if 是通过其后的命令执⾏完成的结果$? = 0 #执⾏成功$? = 1 #执⾏失败从⽽判断条件的真/假#!/bin/bashtest -e findecho $?test -e find1echo $?[ -e find ]echo $?[ -e find1 ]echo "⼲扰" #执⾏成功 $?=0

echo $?010⼲扰0

发布者:admin,转转请注明出处:http://www.yc00.com/xiaochengxu/1690917861a463156.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信