Help needed to modify search functionality

Hi Folks -

I have the following file:

This file is exported after various steps of my data integration routine. I need to be able to dynamically download the latest logfile from this list that starts with a path of " outbox/logs/", all other entries can be ignored.

I have the following code which works if I know the name of the log:

_FDMEE_LOG="$(sort -r temp.txt | sed -n "\#${_OUTBOX_BIN}FINPLAN_# {s#.*/##; p; q}")"

I need to be able to find the latest file, regardless of the name as long as it starts with " outbox/logs/". I tried to add a wildcard to the above logic but it doesn't work. Can someone help me editing my syntax?

THe result should be : outbox/logs/FINPLAN_2201.log based on my sample data.

Thank you!

Hi
how about?

grep '^outbox\/logs\/' temp.txt | tail -1

--- Post updated at 11:35 ---

maybe so

grep '^outbox\/logs\/' temp.txt | sort -t_ -nk2,2.4 | tail -1

or

grep '^outbox\/logs\/' temp.txt | sort -V | tail -1
2 Likes

They all worked flawlessly!!! Thank you so much!