FYI, the code you've given simply doesn't work. If you actually have some working code, then run it to check that it works and copy and paste the full code please.
That's simple. What do you have so far?Anyway, let's focus on the other problem now.
This is a discussion on total login time of each user in last within the Linux Programming forums, part of the Platform Specific Boards category; FYI, the code you've given simply doesn't work. If you actually have some working code, then run it to check ...
FYI, the code you've given simply doesn't work. If you actually have some working code, then run it to check that it works and copy and paste the full code please.
That's simple. What do you have so far?Anyway, let's focus on the other problem now.
The human mind treats a new idea the way the body treats a strange protein; it rejects it. - P.B.Medawar
How come? I had run it before and worked fine. How about that?
I haven't started at all, because I am stuck.Code:res="$( last | grep -v "wtmp" ) users="$( echo $res | awk '{print $1}' | sort -u )" for user in $users; do totmin=0 qq=$( echo "$res" | grep "$user" | grep -v "still logged in" | awk '{print $NF}' | sed 's/[()]//g' ) for q in $qq; do min="$( echo $q | awk -F: -v hrs=0 -v min=0 '{hrs=hrs+$1; min=min+$2}END{min=hrs*60+min;print min}' )" totmin=$(( $totmin + $min )) done qq=$( echo "$res" | grep "$user" | grep "still logged in" | awk '{print $(NF-3)}' if [ -n qq ]; then for q in $qq; do min="$( echo $q | awk -F: -v hrs=0 -v min=0 '{hrs=hrs+$1; min=min+$2}END{min=hrs*60+min;print min}' )" hrs=$( date -u +%H ) mins=$( date -u +%M ) mins=$(( $(($hrs * 60)) + $mins )) min=$(( $mins - $min )) totmin=$(( $totmin + $min )) done fi echo "$user $totminmins" >> rep1.txt
Last edited by vril; 04-20-2012 at 05:33 PM.