I have a directory /foo/bar that contains many files, let's say
c.file and so on.
I am using
grep to search for
xyz pattern inside every file in that directory, but I want to send the result in new files such as
a.new.file if the line was found in
b.new.file if the line was found in
b.file and so on.
grep -ri "xyz" /foo/bar/* works well on screen, every line from the result starts with the path to the file that contains the pattern. Is this path stored in a variable that i can use to create the new files?
a.new.file should be all lines that match
b.new.file should be all lines that match
And so on.