Maybe I'm overlooking something but is there a way to get your current bash history for the current session you are using like
if i run
ssh host $ pwd $ ls $ cd /tmp
I just want to see those 3 commands and nothing else
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
comp to compare the entire history (incl. current Bash session) with the already persisted history in
.bash_history and only print those lines that are unique to the current session -- which should show only those commands that were executed since starting the current Bash shell
comm -23 <( history | cut -c 8- ) ~/.bash_history
Edit: as @Wildcard pointed out this command does not work for all distributions of
comm. I tested this on Mac OS.
A variation of the same idea using
diff <( history | cut -c 8- ) ~/.bash_history | sed -n 's/^< //pg'