Linux search a specific text in specific log files based on date

Issue

I would like a search for a specific text called TEXT_ID but it is taking too much time..

I would like instead to filter the search to only files with a specific date..
My log files have this patters *log.2020-02-25T10.28.01.956-f4b54c

I have tried this but no result:

find /opt/apps/shared/log/ -type f -ls | grep ‘2020-02-24’ | grep -r
“TEXT_ID”

Solution

This command:

find /opt/apps/shared/log/ -type f -ls | grep '2020-02-24' | grep -r "TEXT_ID"

search for specific text in list which contain filenames. You do not search in the content of the files.

You can try something like

find /opt/apps/shared/log/ -type f -name "*2020-02-24* "-exec grep "TEXT_ID" {} \;

Answered By – Romeo Ninov

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published