grep for pattern including carriage return on a Mac
Sophia Terry
I want to search files for colon followed by carriage return followed by dash. I am using macOS (so it's BSD grep).
I would have thought
grep -l ":\n-" filename-pattern
would work, but it doesn't! And using
grep -l ":\n-" filename-pattern
doesn't work either.
Here's the octal dump of the line in question:
0000020 U R D A T A B A S E : \n - TOther posters have noted that since grep is line oriented, I will need to use awk, but I can't seem to get the pattern right - I am using
awk '/:\n- /' filename
1 Answer
Like Gordon said grep won't be able to match multiline statements, but awk will be able to. Here is another question that will hopefully help you build the proper statement that you are looking for. Good luck!