Hi folks
I have some logfiles like this:
./2009_08_22_14_08_entire_backup_no_1.log
.
.
.
./2009_08_22_14_34_entire_backup_no_14.log
each one contains a timestamp from "date +'%s'"
now i need function which finds the logfile with the greatest number in it and returns (echos) the filename.
how can this be done?
I know this is not it..but a start..
function find_most_recent_entire_backup(){
# read the logfile of the most recent entire_backup and
for f in `find ./ -type f -regex ".*entire.*.log" `; do
timestamp=`grep [1,2,3,4,5,6,7,8,9,0] $f`
echo $timestamp
done
}
thank you already
Post the file contents within CODE tags.
tyler_durden
ok i will ...
did i make my point? did i discribe right what i want to do?
any ideas?
Something like this?
awk -F"./" '{d=substr($2,1,16);gsub("_","",d)}d>g{g=d;f=$0}END{print f}' file
ok time for me to learn awk...
any good tutorials on hand??
embaressing ..but i do not understand this oneliner at all
just running it at the prompt does not do it:
0:521:root@x301 /lvdata/backupdir [0]# find ./ -type f -regex ".*entire.*.log"
./2009_08_22_14_08_entire_backup_no_1.log
./2009_08_22_14_34_entire_backup_no_1.log
0:522:root@x301 /lvdata/backupdir [0]# for f in `find ./ -type f -regex ".*entire.*.log" `; do timestamp=`grep [1,2,3,4,5,6,7,8,9,0] $f`; echo $timestamp; done
1250942903
1250944466
0:523:root@x301 /lvdata/backupdir [0]# awk -F"./" '{d=substr($2,1,16);gsub("_","",d)}d>g{g=d;f=$0}END{print f}' file
awk: Kommandozeile:1: Fatal: Kann Datei 'file' nicht zum Lesen �ffnen (Datei oder Verzeichnis nicht gefunden).
0:524:root@x301 /lvdata/backupdir [2]#
thank you
In that case:
find ./ -type f -regex ".*entire.*.log" |
awk -F"./" '{d=substr($2,1,16);gsub("_","",d)}d>g{g=d;f=$0}END{print f}'
Regards
man this feels funny... using some code i do not have a cloue about....lol
well it does it s thing..thnak you for that
and i am learning awk now...promise!!!
:rolleyes:
Or maybe this:
ls -1 *entire*log | sort -t_ -nrk1,5 | head -1
tyler_durden