In a script, I want to find files that contain some text. I need to know the file the text is found in, and the full line within the file that the text is found in.
grep is the utility that does this, but how can I get the output into a usable form, given that there can be
: in filenames? Is there some sort of
--porcelain mode for
grep that I can use, kinda like
git commands often have?
Example: I have a folder full of files named like
test-num:1:date:jan-2 that I want to grep through. The files contain
FAILURE:<some reason> or
SUCCESS:<some reason> (among other stuff). I need a script that searches for certain reasons and stores the name of the file, and the reason (the whole line of text is fine) for later processing. The output can be in any sort of data structure, as long as I can run code over it.