Results 1 to 2 of 2
I need some help. I want to create a script to tell me info about all users from a system who logged in in the last month, at least 3 ...
- 03-21-2008 #1Just Joined!
- Join Date
- Mar 2008
- Posts
- 1
Bash scripting
I need some help. I want to create a script to tell me info about all users from a system who logged in in the last month, at least 3 times. I made this over far but I need for all users... To get all users from /etc/passwd not to type them from keyboard... Can someone help me ?Thanks.

if [ $# = 0 ]
then
echo "Enter user: "
else
for i
do
last -3 $i || echo "The user $i never logged in!"
done
fi
- 03-21-2008 #2Linux User
- Join Date
- Aug 2006
- Posts
- 458
Code:awk 'BEGIN{FS=":"} { cmd="last -3 " $1 while( (cmd | getline result )>0 ) { if ( result ~ $1 ) { print result } } close(cmd) }' /etc/passwd


Reply With Quote