I am trying to display the user name of the accounts that have logged in during the past month using the last command.
At the moment I have this
last | awk '{print $1, $4 ,$5 ,$6}' | grep -B 10 Jul | sort -u -t' ' -k1,1 As the users who have logged in most recently are displayed higher in the list, I am trying to grep for the month, then display that line and the lines above it and delete duplicate usernames. But it doesn't seem to be working. Any ideas?
-B 10; please try to explain that better. (3) "It doesn't seem to be working" is very vague. What does it do? (4) Have you tried breaking it down into pieces? For example, dolast | awk '{print $1, $4, $5, $6}'and see whether the output is what you expect, and then work from there.last -t?lastshow any entries for July?