
以下を使って検索しようとするとlocate
:grep
locate A-B | grep .dir
結果:
.../A-B-C.dir
.../A-B-C.dir/file
.../A-B-C.dir/file1
.../A-B-D.dir
.../A-B-D.dir/file1
...
検索をこれより少なく変更またはgrep
作成するにはどうすればよいですか?locate
.dir
私は非常に古いシステムを持っています。
Secure Locate 2.7 - 2003年1月24日リリース
grep (GNU grep) 2.5.1
答え1
Linuxシステムの場合、locate
正規表現をサポートする可能性が高いです。
locate --regex 'A-B.*\.dir$'
そうでなければ、
locate 'A-B' | grep '\.dir$'
主なポイントは、行の末尾に正規表現を正しく固定することです$
。
/some/path/ABBA-Bootlegs/thing.dir
どちらのバリエーションも、例えば見つけることができます。