bash script to find date based on search string for continuesly updating file

Hi All,

I am very new to UNIX and I have tried this for a longtime now and unable to crack it....

There is a file that is continuously updating. I need to search for the string and find the date @ which it updated every day.....

eg:

String is "work started"
The log entry is as below:

2020 Jan 01 15:45 The work that has been scheduled has been picked up | Now the work will start within few mins | Thanks for Waiting fo so long for the work to start | work started |

Now i need to find the entry "work started "... if it is found i need the date "2020 Jan 01 15:45" to be recorded...

the crack point is that the when i search on the first day i can find it... so what can i do for the second day???

Help me out guys....

Hi, try:

awk '/work started/{print $1,$2,$3,$4}' file

Otherwise what have you tried that only found the first entry?