linux - Grep latest file string -
system: aix 7.1
let's have folder files these:
the files need have prefix sapemea_postatus.log.xxxxxxxx, , inside of them have number (collection number), this:
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
Post a Comment