shell script if
shell if
$ test 1 -ge 1 ; echo $? # a -ge b → a >= b
$ test 1 -eq 1; echo $? # 0(true)
https://qiita.com/egawa_kun/items/196cd354c0d8e4e0fefc
$ if -f a.txt # ファイルであれば真
$ if -s a.txt # ファイルが存在し空でなければ真
$ if "" # false
$ if "a" # true
$ if [ echo ab ] # true
$ if [ "echo 'a b'" ] # true(期待どおり)
$ case echo "a b" in # ok
$ ! "a" # false
$ if -f a.txt && ! -f z.txt # a.txtが存在 かつ z.txtが存在しない
$ if which ccat > /dev/null 2>&1;then # ccatがあったら
コマンド成功/失敗を判定できる
ifの後に好きな(複数行にまたがる)コマンドを書いてよい
? shell scriptの(if|比較)
shell script
code:a.sh
function abc(){
if $# -eq 0
then
elif $1 = "-e"
then
fi
}
文字列比較は=
if [ "a" = "a" ] 推奨