qrを含むコンテンツを検索する正規表現は何ですか?

qrを含むコンテンツを検索する正規表現は何ですか?
grep -rlw . -e '%QR%' 

私はこのようなことをしています。 QRの前には何でも来ることができ、QRの後には何でも来ることができます。または何もないかもしれません。

コンテンツ(名前ではない)にQRを含むファイル名を探しています。

これを検索に組み込む方法のアイデア。 SQLでは、上記のように開始と終了に%を追加します。

ベストアンサー1

grep 'something' file(s)
  # look for lines containing the substring "something" 
  # in the file (or all files). 
  # note: if several files it will add "filename:" in front of each lines, but does not look in those filenames

some program | grep 'something'
 # look for lines of output of "some program" 
 #  containing the substring 'something' 

したがって、「QR」を含むファイル名を見つけるためにgrepが必要な場合は、次のことができます。

ls | grep "QR"  # or ls -R | grep QR

ただし、lsを解析しないことをお勧めします(改行やスペースを含むファイルなどの多くのトラップがあります)。find代わりに?

find /some/path -type f -name '*QR*' 
-or-
find /some/path -type f -name '*QR*' -ls
 # to get the long output, showing infos on each files found.
 # note: this exemple only matches regular files, not symlinks nor pipe nor directories

「QR」が記載されているファイル名を見つけたら、次のことができます。

grep -r -l "QR" /some/path
  # l = lowercase L = list filenames matching
  # r = recursively from /some/path or ./relative_path

おすすめ記事