[AIX]grepのドット(.)やアスタリスク(*)の意味
マニュアルに下記の記載がある通り、grepコマンドではドット(.)やアスタリスク(*)は特殊な意味を持ちます。
The patterns are limited regular expressions in the style of the ed
edコマンドのマニュアルには下記の記載があります。
.
Matches any single character except the new-line character.
* An RE followed by an * (asterisk) matches zero or more occurrences of the character that the RE matches. For example, the following pattern:
ab*cd
matches each of the following strings:
acd
abcd
abbcd
abbbcd
but not the following string:
abd
If a choice exists, the longest matching leftmost string is chosen. For example, given the following string:
122333444
the pattern .* matches 122333444, the pattern .*3 matches 122333, and the pattern .*2 matches 122.
つまり、ドット(.)は任意の1文字を示し、アスタリスク(*)は0個以上の連続を示します。
lsコマンドなどksh系のファイル名展開では、 *.*などでドット(.)という文字を含むファイルを探すことができますが、ls | grep "*.*"とすると任意の1文字の0個以上の連続を含むファイル、という意味になり、全てのファイルが表示されます。
また、AIXの既知の制限事項として、マルチバイトロケールでドット(.)を使用した正規表現(regular expressions)の検索が再帰関数で行われるというものがあります。
検索パターンに含まれるドット(.)の数や検索対象行の長さにも依存しますが、再帰関数がスタックを大量に使用しcoredumpが発生する場合があります。
match_dot()が大量に呼ばれ、スタックポインタ(r1/stkp)のデクリメントでcoreが出力されている場合は、上記制限に該当したと考えられるため、検索パターンの見直しやLANG=Cでのgrep実行が推奨されます。
上記制限の変更はIBM Ideasから要求することができます。
参考: 製品改善要望(IBM Ideas) のご案内
https://community.ibm.com/community/user/discussion/ibm-ideas-1