See last login datetimes on a RedHat Linux server
$ cat userlist.sh
# Name of the server to be prepended to each line?
SERVER=R18-PRMY
# Nothing user-editable below
NOW=`date '+%Y%m%d'`
FILENAME=users_CMS-$SERVER-$NOW.txt
# Create or Empty the file
> $FILENAME
lastlog | awk -v server="$SERVER" '{print server " " $0 "\n"}' | tr -s '\n' > $FILENAME
Gives output like below. I don't see a flag in lastlog
that turns off headers.
R18-PRMY Username Port From Latest
R18-PRMY cms pts/14 1.2.3.4 Mon Dec 18 16:59:22 -0500 2017