Reputation: 183
I am searching something logs at the following directory
$ cd opt/app/abc/logs
Now the logs folder contains many different logs like
abc.log
def.log
wer.log
Now I need to search something in logs that I am doing n the following way as I wanted to know the names of the files first in which that entry is , Let say I am searching string 456
$bash
$ cd opt/app/abc/logs
$ grep -l 456 *
now I also want that it should store all the records of string 456 in a separate text file at the same location so that after that I can open that file to see the results sum up of string 456. How to achieve this?
Upvotes: 0
Views: 78
Reputation: 16037
Just output the command to a file:
grep -l 456 * > somefile.txt
You can do this for any command.
Upvotes: 1