Hello, On Sat, 19 Apr 2008, David C. Rankin wrote:
I had to parse a file to find the max cputemp and I wanted to do it from the command line. There were several thousand lines of .25 sec cputemp data captured while mprime was running. The file format and the command line I came up with are:
input:
04:18 trinity~/linux/scripts> tail cputemp.log 20080419 02:32 65.0 C 20080419 02:32 65.0 C <snipped>
command line and output:
04:17 trinity~/linux/scripts> tmax=0; while read a b t c; do t=$(echo "$t" | sed -e 's/\.//'); if (( $t > $tmax )); then tmax="$t"; fi; done < ./cputemp.log ; tmax=$(echo "$tmax" | sed -e 's/\([0-9][0-9]\)\([0-9]\)/\1\.\2/'); echo "Max temp is: $tmax"
Max temp is: 69.5
Easy: awk and perl were created for this kind of stuff. awk '$3 > tmax { tmax = $3; } END { printf "Maximum temperature was: %.1f °C\n", tmax; }' cputemp.log More elaborate with the following input: ==== 20080419 02:32 63.3 C 20080419 02:34 64.1 C 20080419 02:36 63.9 C 20080419 02:39 65.3 C 20080419 02:42 64.2 C 20080419 02:49 65.32 C 20080419 02:53 65.3 C 20080419 03:02 64.2 C ==== $ awk ' $3 > tmax { tmax = $3; tdate = $1; ttime = $2; } END { printf "Maximum temperature was: %.1f °C on %s %s\n", tmax, tdate, ttime; }' cputemp.log Maximum temperature was: 65.3 °C on 20080419 02:49 HTH, -dnh --
Mine had one where I think 4 machines were so intertwined that none would boot unless 2 of the others were up. And nothing else would boot till those were up. You are trapped in a maze of twisty little NFS-maps, all different. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org