zshで単一の角括弧で囲まれた複数のif条件

zshで単一の角括弧で囲まれた複数のif条件

次のコマンドはbashでうまく機能します。

find . -depth -name Chart.yaml -exec sh -c 'f="{}"; if [[ ($f =~ ./api-*) && !($f =~ ./api-pnp-*) && !($f =~ ./api-edb-*) ]]; then tmpifs=`echo $IFS`; verstr=`grep version $f`; IFS=" "; read -r -a strarr5 <<< $verstr; if [[ $strarr5[2] =~ ([0-9]+).([0-9]+)* ]]; then IFS=“.” read -r -A verno <<< $strarr5[2]; Minornew=`echo $verno[2]+1 |bc`; Minorold=`echo $verno[2]`; sed -i '.bakrohit' "s/$Minorold/$Minornew/g" $f; echo $f $Minorold $Minornew; fi; fi;' \;

ただし、zshの同じコマンドは追加のif条件をエスケープします。"!($f =~ ./api-pnp-*) && !($f =~ ./api-edb-*)"

find . -depth -name Chart.yaml -exec zsh -c 'f="{}"; if [[ ($f =~ ./api-*) && !($f =~ ./api-pnp-*) && !($f =~ ./api-edb-*) ]]; then tmpifs=`echo $IFS`; verstr=`grep version $f`; IFS=" "; read -r -A strarr5 <<< $verstr; if [[ $strarr5[2] =~ ([0-9]+).([0-9]+)* ]]; then IFS=“.” read -r -A verno <<< $strarr5[2]; Minornew=`echo $verno[2]+1 |bc`; Minorold=`echo $verno[2]`; sed -i '.bakrohit' "s/$Minorold/$Minornew/g" $f; echo $f $Minorold $Minornew; fi; fi;' \;

api-*にはapi-edb-*とapi-pnp-*が含まれていますが、除外したいと思います。

zshで複数のif条件をまとめる方法。

ベストアンサー1

おすすめ記事