シェルスクリプト難しい…。
結論
pattern=[ABC] if [[ "$i" == $pattern ]]; then echo "$i mathces pattern $pattern." else echo "$i does not mathces pattern $pattern." fi
その他
#! /bin/bash for i in A B C ABC "[A]" do if [ "$i" = 'A' ]; then echo "$i is A." else echo "$i is not A." fi if [[ "$i" = 'A' ]]; then echo "$i is A." else echo "$i is not A." fi pattern=[ABC] if [ "$i" == $pattern ]; then echo "$i mathces extended $pattern." else echo "$i does not mathces extended $pattern." fi if [[ "$i" == $pattern ]]; then echo "$i mathces pattern $pattern." else echo "$i does not mathces pattern $pattern." fi echo -e "" done
参考

- 作者:三宅 英明
- 発売日: 2017/11/21
- メディア: 単行本