これをどうやってgrepしますか? (特殊文字を含む)
"Limit reached."[\n]"
特殊記号をバックスラッシュしようとしましたが、最終的には次のように動作しませんでした。
grep '\"Limit reached\.\"\[\\n\]\" '
他の技術も試してみましたが、やはり効果がありませんでした。提案/提案できる他の構文はありますか?
ベストアンサー1
grepで-Fを使う
$ cat test.txt
"Limit reached."[\n]"
test
"Limit reached."[\n]"
$ grep -F '"Limit reached."[\n]"' test.txt
"Limit reached."[\n]"
"Limit reached."[\n]"
マニュアルページによると、
-F, --fixed-strings, --fixed-regexp Interpret PATTERN as a list of fixed strings, separated by newlines, any of which is to be matched. (-F is specified by> POSIX, --fixed-regexp is an obsoleted alias, please do not use it new scripts.)