1
2

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 拡張の extglob ファイルパターンマッチについてのメモ

Posted at

extglob によって、ファイルパターンマッチにおいて、正規表現におけるグループ化のようなことができる。厳密な詳細は、公式マニュアル参照

$ shopt -s extglob

$ ls
abra  abracadabra  avada  cadabra  kedavra

$ echo ?(a@(br|vad)a)?(@(ke|ca)da[bv]ra)
abra abracadabra avada cadabra kedavra

このオプションは、 bash のパーサーに影響を与えるらしく、このオプションが off の時には、次のコマンドは文法エラーになる。

$ shopt -s extglob; echo ?(a@(br|vad)a)?(@(ke|ca)da[bv]ra)
-bash: syntax error near unexpected token `('
1
2
0

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
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?