$ echo "$(lastlog | grep $USER | awk '{print $(NF-5)" "$(NF-3)" "$(NF-4)" "$(NF-2)" "$(NF-1)" "$(NF-0)}')"
Thu 7 Sep 05:56:35 +0100 2023
I want to replace the +0100
bit with BST
or GMT
if the value is +0000
(I am aware that this output is probably dependent on the locale).
I did test for the value of $(NF-1)
to conditionally set a variable, but I don't know how to put the variable within the awk print command.
I also want to put an extra space between $(NF-5)
and $(NF-3)
when $(NF-3)
(the date) is a single digit, but not when it is two digits.
How best can this be done?