I would like to print last bash command with its timestamp. history 1 shows the history command itself. I need to use it on many machines, so it should not depend on any custom configuration. There surely must be some simple command that I am missing to do this, like lastcmd or something :)Note that fc -l -1 shows the last command but without timestamp, and is too complicated to type it frequently anyway.Just to clarify, I am looking for some standard and simple way to do this because I need to use it on many servers and it is not feasible to customize them all or create custom functions. Also I need to type this command manually so it should be really simple.It seems that HISTCONTROL=ignoreboth is a default setting on servers I need to access so I can use: history 1 (history command prefixed with a space) which does not put it in the history, so it correctly shows the last command.HISTTIMEFORMAT is not set by default though, so it is not a complete solution. Is there a simpler way?
Simplest standard way to print last bash command with timestamp
bash;command history
It seems that bash does not out of the box provide any simple way to get timestamp when the last command was executed.In case it is practical for you to customize your servers bash configs you can create custom bash function based on the answer from @terdon. 