Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

8
  • history | tail -1 | awk '{print $1}' can be simplified to history 1 | awk '{print $1}' Commented Aug 20, 2018 at 18:49
  • -bash: tac: command not found on Mac OSX, otherwise this would be the best answer.
    – Zim
    Commented Jan 24, 2020 at 17:38
  • for h in $(seq 1006 1008); do history -d 1006; done this works in ubuntu 16.04
    – mahfuz
    Commented May 22, 2020 at 17:54
  • 1
    Short but sweet: for i in {1..10}; do history -d $(($HISTCMD-11)); done
    – alchemy
    Commented Jun 3, 2020 at 14:38
  • 1
    @alchemy replace the '11' with 'i' and then yes, this works perfectly!
    – E. Körner
    Commented Jul 9, 2021 at 14:05