I have search the forum and could not find an answer...Here is what I am trying to do. Every 15 minutes, a script send uptime output to a logfile (dailylog.log), that file contains lines like the one below:
Now, I am trying to extract only the before last line and send it to another file. The thing is that using tail -2 will show me the last 2 lines... I don't need that last line. The log is growing every 15 minutes so I don't know how many entries there are in the file.
Tks Jim. Now what I do is putting the 13th argument of uptime command in a variable, the load, let's say 0.06 and now adding the last 24 hours load and doing an average of the total. Here is what I am trying to do:
#!/usr/bin/ksh
I_COUNT=96
C_CHAINE=0
until ((I_COUNT < 1))
do
tail -$I_COUNT /dailyload.log | head -1 | awk '{print $13}' > $C_CHAINE
#average
((C_CHAINE=C_CHAINE+$13))
((I_COUNT=I_COUNT-1))
done
((C_CHAINE=C_CHAINE/96))
echo $C_CHAINE
It might however be better to count the colum from the right, rather then the left, because the time in uptime may not always contain the same numbert of fields.