Timeline for How to delete history of last 10 commands in shell?
Current License: CC BY-SA 4.0
15 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
May 15, 2023 at 17:40 | comment | added | phuclv | @JGC indeed, my bad | |
May 15, 2023 at 16:17 | comment | added | JGC | @phuclv - No, because as you delete history the positions change, so to delete 1006 to 1008, you delete 1006 3 times. | |
Jan 15, 2022 at 13:36 | comment | added | dgmz | @georgeHilliard no that is not the same. the first returns one occurence, the second a list, which is not what we want | |
Jul 9, 2021 at 14:05 | comment | added | E. Körner | @alchemy replace the '11' with 'i' and then yes, this works perfectly! | |
Jun 3, 2020 at 14:38 | comment | added | alchemy |
Short but sweet: for i in {1..10}; do history -d $(($HISTCMD-11)); done
|
|
May 22, 2020 at 17:54 | comment | added | mahfuz |
for h in $(seq 1006 1008); do history -d 1006; done this works in ubuntu 16.04
|
|
S Jan 24, 2020 at 21:25 | history | suggested | Zim | CC BY-SA 4.0 |
use of 'tac' assumes linux, this question pertains to all bash terminals
|
Jan 24, 2020 at 17:41 | review | Suggested edits | |||
S Jan 24, 2020 at 21:25 | |||||
Jan 24, 2020 at 17:38 | comment | added | Zim |
-bash: tac: command not found on Mac OSX, otherwise this would be the best answer.
|
|
Aug 20, 2018 at 19:02 | history | edited | JGC | CC BY-SA 4.0 |
Updated to use simpler commands.
|
Aug 20, 2018 at 18:49 | comment | added | George Hilliard |
history | tail -1 | awk '{print $1}' can be simplified to history 1 | awk '{print $1}'
|
|
Apr 25, 2016 at 17:51 | review | Late answers | |||
Apr 25, 2016 at 17:57 | |||||
Apr 25, 2016 at 17:44 | history | edited | JGC | CC BY-SA 3.0 |
Tailored the final portion to the exact question.
|
Apr 25, 2016 at 17:28 | review | First posts | |||
Apr 25, 2016 at 17:42 | |||||
Apr 25, 2016 at 17:26 | history | answered | JGC | CC BY-SA 3.0 |