xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub! Linux bash fi

xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!
Linux bash fi

if..else..fi allows to make choice based on the success or failure of a command.

if..else..fi 允许根据命令的成功或失败进行选择。

if [ conditional expression ]
then
	statement1
	statement2
	.
fi

if [ expression ] 
then 
   Statement(s) to be executed if expression is true 
fi


demo


if [ ! -x /usr/bin/axel ]
then echo "axel is not installed, perform this?(y/n)"
    read ops
    case $ops in
     y) if apt-get install axel -y --force-yes
           then echo "axel installed"
        else echo "unable to install the axel. you are using sudo?" ; exit
        fi ;;
     n) echo "not possible usage apt-fast" ; exit ;;
    esac
fi

https://*.com/questions/7010830/bash-whats-the-use-of-fi

refs

https://bash.cyberciti.biz/guide/If..else..fi

https://www.tutorialspoint.com/unix/if-fi-statement.htm



©xgqfrms 2012-2020

www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!