8
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

[ bash ] 正規表現パターンマッチング

Posted at

##memo

while read input_data; do
    if [[ ! ${input_data} =~ [Aa] ]]; then
        echo ${input_data}
    fi
done

入力された文字列に「A」または「a」があったらechoしない、というサンプル
ポイントは

  1. [[]] 二重に囲む
  2. =~(イコール+チルダ)
  3. ダブルクォーテーションで正規表現囲まない
8
9
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?