I use the command: finger `sort /etc/passwd | cut -f1 -d":"` | grep -i log > /userlist.txt
This outputs to the file userlists.txt information as follows:
Login name: XXXXXXXX
Never logged in.
Login name: XXXXXXXX
Last login Mon Mar 7, 2011 on pts/31 from
Login name: XXXXXXX
Last login Mon Aug 12 08:40 on pts/6 from XXX.XXX.XXX.XXX
Login name: XXXXXXXX
Last login Wed Sep 4 21:28 on pts/4 from XXX.XXX.XXX.XXX
I want to put this into a script that I can execute instead of having to enter the command every time (or copy and paste it)
However, when I put this in a script and execute it, it only provides and output of the sorted passwd file on the screen and doesn't write to the file.
So I get this on the screen and nothing else:
root 0 root 0 Super-User
root2 0 root 0 Super-User
daemon 1 other 1
bin 2 bin 2
sys 3 sys 3
adm 4 adm 4 Admin
etc, etc, etc.....
How can I get the command to run correctly and output to the file in a script?
- Stinney
"Scire ubi aliquid invenire possis, ea demum maxima pars eruditionis est"
"To know where to find anything is, after all, the greatest part of education"