linux - Grep latest file string -


system: aix 7.1

let's have folder files these:

enter image description here

the files need have prefix sapemea_postatus.log.xxxxxxxx, , inside of them have number (collection number), this:

enter image description here

and have questions

hey, collection number last 1 have?

so have open ftp, navigate folder, filter column show newest ones in top, latest sapemea_postatus.log file, download , check notepad++.

so question is: there way make grep command can filter kind of files, recent one, , show collection number? thanks!

#!/bin/bash  latest_collection=0  regex="collection:[ ]*([0-9]+)"  log in sapemea_postatus.log.*;      [[ $(cat $log) =~ $regex ]]     collection="${bash_rematch[1]}"      if [[ $collection > $latest_collection ]];         latest_collection=$collection         latest_log=$log     fi done  echo "latest log: $latest_log (number $latest_collection)" 

Comments

Popular posts from this blog

java - pagination of xlsx file to XSSFworkbook using apache POI -

Unlimited choices in BASH case statement -

apache - How do I stop my index.php being run twice for every user -