码迷,mamicode.com
首页 > 系统相关 > 详细

linux 杂

时间:2017-05-10 18:57:38      阅读:215      评论:0      收藏:0      [点我收藏+]

标签:fail   access   path   amp   管道   color   command   not   pre   

set -e表示一旦脚本中有命令的返回值为非0,则脚本立即退出,后续命令不再执行;

set -o pipefail表示在管道连接的命令序列中,只要有任何一个命令返回非0值,则整个管道返回非0值,即使最后一个命令返回0.

---------------------------------------------------------------------------------------------------------------------------------------------------------------

tput rev  # reverse                    命令行背景反转
tput bold # bold                         字体加粗
echo ‘Please provide a path to a SSH private key to access Manta.‘
tput sgr0 # clear                         回归原状

---------------------------------------------------------------------------------------------------------------

if [ -z "$1" ]; then               是空

if [ ! -f "$1" ]; then             文件不存在

---------------------------------------------------------------------------------------------------------------

$ command -v foo >/dev/null 2>&1 || { echo >&2 "I require foo but it‘s not installed.  Aborting."; exit 1; }
$ type foo >/dev/null 2>&1 || { echo >&2 "I require foo but it‘s not installed.  Aborting."; exit 1; }
$ hash foo 2>/dev/null || { echo >&2 "I require foo but it‘s not installed.  Aborting."; exit 1; }

判断命令是否存在

------------------------------------------------------------------------------------------------------------------------

linux 杂

标签:fail   access   path   amp   管道   color   command   not   pre   

原文地址:http://www.cnblogs.com/mhc-fly/p/6837388.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!