If I want to do a grep on the files on the whole server I can do the following:
Code:
find / -type f -exec grep '<what I want to grep>' '{}' \;
What if I want to pipe the "grepped" output for further processing? I can't just simply do this. It just doesn't work.
Code:
find / -type f -exec grep '<what I want to grep>' '{}' \; | grep '2nd level of grep'
How about I want to find the number of occurrences per file returned? For example, if the output of the first command above returns...
Code:
file 1: ad;flkjasd;lfk <what I want to grep> asdfl;kj
file 1: ad;flkjasd;lfk <what I want to grep> asdfl;kj
file 2: ad;flkjasd;lfk <what I want to grep> asdfl;kj
file 3: ad;flkjasd;lfk <what I want to grep> asdfl;kj
file 4: ad;flkjasd;lfk <what I want to grep> asdfl;kj
How do I structure the command so I can see something like?
Code:
file 1: 2
file 2: 1
file 3: 1
file 4: 1