首页 > 代码库 > linux 杂
linux 杂
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 杂