cancel
Showing results for 
Search instead for 
Did you mean: 
jeesshnasree
Starfighter Starfighter
Starfighter
  • 627 Views

grep string less than minute files with path

Jump to solution

Hi All,


I have one query for search string in un-known files in Linux OS but file time stamp is less than a minute only while search , if possible any command as per criteria then please share command .

 

grep "success" string in a unknown-file before one minute .

Below 2 out puts  need as per search string .


1) print file name 

2) full path of the file

Example : 

grep "success" /tmp/my-test/testing/logs/mars/water/*/logs/*.*
out put of the file or files with path

condition is less than a minute .

 

I hope explained query clearly . 

I am waiting for your valuable information .

 

Regards,

Jeesshnasree

Labels (1)
1 Solution

Accepted Solutions
shura
Flight Engineer
Flight Engineer
  • 614 Views

Hi

find /tmp/my-test/testing/logs/mars/water -mmin -1 -exec grep -l "success" {} \;

and then follow https://learn.redhat.com/t5/General/Print-end-of-the-directory-only/m-p/45154#M8887

variant:

tty=$(tty) ; find  /tmp/my-test/testing/logs/mars/water -mmin -1 -exec grep -l "success" {} \; | tee $tty | sed 's|.*/\(.*$\)|\1|'

View solution in original post

4 Replies
shura
Flight Engineer
Flight Engineer
  • 615 Views

Hi

find /tmp/my-test/testing/logs/mars/water -mmin -1 -exec grep -l "success" {} \;

and then follow https://learn.redhat.com/t5/General/Print-end-of-the-directory-only/m-p/45154#M8887

variant:

tty=$(tty) ; find  /tmp/my-test/testing/logs/mars/water -mmin -1 -exec grep -l "success" {} \; | tee $tty | sed 's|.*/\(.*$\)|\1|'

jeesshnasree
Starfighter Starfighter
Starfighter
  • 601 Views

water-success-results.png

Hello @shura ,

 

Thank you so much , its working now .

 

Regards,

Jeesshnasree

shura
Flight Engineer
Flight Engineer
  • 592 Views

Hi

you miss first "t" in variant's example, check, please. Result should be more usefull

jeesshnasree
Starfighter Starfighter
Starfighter
  • 583 Views

Hi @shura ,

 

 

Thank you so much & done . water-success-results-awesome.png

Join the discussion
You must log in to join this conversation.