I want this:
sojjan pts/9 localhost Thu Oct 13 08:04:14 2016 - Thu Oct 13 08:04:15 2016 (00:00)
gurra pts/9 localhost Wed Oct 12 15:36:00 2016 - Wed Oct 12 15:36:02 2016 (00:00)
sojjan pts/8 :0 Wed Oct 12 10:13:34 2016 still logged in
sojjan pts/7 :0 Mon Oct 10 13:34:56 2016 still logged in
To become like this:
Last 24h SSH logins:
sojjan pts/9 localhost Thu Oct 13 08:04:14 2016 - Thu Oct 13 08:04:15 2016 (00:00)
gurra pts/9 localhost Wed Oct 12 15:36:00 2016 - Wed Oct 12 15:36:02 2016 (00:00)
Still logged in:
sojjan pts/8 :0 Wed Oct 12 10:13:34 2016 still logged in
sojjan pts/7 :0 Mon Oct 10 13:34:56 2016 still logged in
I tried as
#!/bin/bash
test0=$(last -F | grep still)
test1=$(date | awk {'print $2, $3'});
test2=$(date --date='-1 days' | awk {'print $2, $3'});
last -F | grep -v 'reboot' | grep -i "$test0\|$test1\|$test2"