bin sh DAYS 90 if -eq then DAYS fi real_accounts cat etc passwd awk BE

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
#!/bin/sh
DAYS=90
if [ $# -eq 1 ]
then
DAYS=$1
fi
real_accounts=`cat /etc/passwd | awk 'BEGIN {FS=":"} {print $1,$7}' | grep -v '/bin/false' | awk 'BEGIN {FS=" "} {print $1}'`
active_accounts=`lastlog -t$DAYS | awk 'BEGIN {FS=" "} {print $1}'`
for user in $real_accounts
do
for test_user in $active_accounts
do
if [ "$user" = "$test_user" ]
then
echo $user
fi
done
done