Hi,
#!/usr/bin/ksh
typeset -i SINCE=${1:-1}
date '+%Y +%m %d %H %M' | read year month day hour min
(( min -= SINCE ))
(( min < 0 )) && { (( min += 60 )) ; (( hour -= 1 )) }
(( hour < 0 )) && { (( hour += 24 )) ; (( day -= 1 )) }
(( day <= 0 )) && {
(( month -= 1 ))
(( month <= 0 )) && { (( month=12 )) ; (( year -= 1 )) }
day=$(cal $month $year | tr '\n' ' ' | awk '{print $NF}')
}
ts5=$(printf "%02d%02d%02d%02d" $month $day $hour $min)
LANG=C who -s |
awk -v ts5="$ts5" -F '[ \t:]*' '
function to_timestamp(month, day, hour, min) {
m = index("_,jan,feb,mar,apr,may,jun,jul,aug,sep,oct,nov,dec,", "," tolower(month) ",")/4;
return sprintf("%02d%02d%02d%02d", m, day, hour, min);
}
to_timestamp($3, $4, $5, $6) >= ts5
'
$
Get Answers For Free
Most questions answered within 1 hours.