How do I find files containing some particular text containing newlines and plenty of other charachters all sorts of quotes and backslashes using terminal?
1 Answer
grep is somewhat line-based, so matching across line boundaries might be problematic with it. If you've the memory to spare, match against the whole file with e.g. perl:
$ (echo fish; echo cat; echo dog; echo frog) \ | perl -0777 -nE 'say $1 if m/(cat.dog)/s' The "all sorts of quotes and backslashes" bit will likely mostly be avoiding shell interpolation rules, e.g. via '\'' type tricks or see ascii(7) and then in perl use an appropriate \047 or \x52 or whatever as necessary. Lacking the memory to load the file, strings(1) might first be used to reduce the amount of data to search.
egrepto search with regular expression. As I do not know what exactly you're searching for, I can tell you thisfind /dir -type f | xargs egrep '---' Replace'---'` with actual regex