The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #6 (permalink)  
Old 04-26-2007
ughosting ughosting is offline
Registered User
  
 

Join Date: Apr 2007
Posts: 3
My Linux code for those interested

#!/bin/bash

NUM_DAYS="0"
TODAY_CODE=$(echo "$(date +%s) / 86400" | bc)

for i in $(cat /etc/passwd | awk -F':' '{print $1}')
do

last | grep ${i} > /dev/null 2>&1

if [ $? -eq 0 ]
then

DATE_TEXT=$(last | grep ${i} | head -1 | awk '{print $5" "$6}')
DATE_CODE=$(echo "$(date -d"${DATE_TEXT}" +%s) / 86400" | bc)
DIFF_DAYS=$(echo "${TODAY_CODE} - ${DATE_CODE}" | bc)

if [ ${DIFF_DAYS} -ge ${NUM_DAYS} ]
then

echo "${i} - ${DIFF_DAYS}"

fi

fi

done