Answer by FIBA for How to delete history of last 10 commands in shell?
#delete ten times the last history line for i in $(seq 1 10)do n=$(history 1 | awk '{print $1}') history -d $ndone
View ArticleAnswer by user2711286 for How to delete history of last 10 commands in shell?
the history -d arg takes a range and $HISTCMD is the max number in the history.This function works to remove the last n entries from history (just pass in the number of history commands to remove like,...
View ArticleAnswer by Thomas Jacob for How to delete history of last 10 commands in shell?
Not directly the requested answer, but maybe the root-cause of the question:You can also prevent commands from even getting into the history, by prefixing them with a space character:# This command...
View ArticleAnswer by Daddef for How to delete history of last 10 commands in shell?
history -d 511;history -d 511;history -d 511;history -d 511;history -d 511;history -d 511;history -d 511;history -d 511;history -d 511;history -d 511;Brute but functional
View ArticleAnswer by alchemy for How to delete history of last 10 commands in shell?
Short but sweet: for i in {1..10}; do history -d $(($HISTCMD-11)); done
View ArticleAnswer by ata for How to delete history of last 10 commands in shell?
I use this (I have bash 4):histrm() { local num=${1:- 1} builtin history -d $(builtin history | sed -rn '$s/^[^[:digit:]]+([[:digit:]]+)[^[:digit:]].*$/\1/p') (( num-- )) && $FUNCNAME $num...
View ArticleAnswer by David Hatch for How to delete history of last 10 commands in shell?
With Bash 5 you can now do a range...Hooray!:history -d 511-520or counting backwards 10:history -d -10--1Excerpt from Bash 5 Man Page:'history'Options, if supplied, have the following meanings:'-d...
View ArticleAnswer by rb1234 for How to delete history of last 10 commands in shell?
Try the following:for i in {511..520}; do history -d $i; echo "history -d $i"; done
View ArticleAnswer by M. Gleria for How to delete history of last 10 commands in shell?
I used a combination of solutions shared in this thread to erase the trace in commands history.First, I verified where is saved commands history with:echo $HISTFILEI edited the history with:vi...
View ArticleAnswer by Junaid for How to delete history of last 10 commands in shell?
I use this script to delete last 10 commands in history:pos=$HISTCMD; start=$(( $pos-11 )); end=$(( $pos-1 )); for i in $(eval echo "{${start}..${end}}"); do history -d $start; doneIt uses $HISTCMD...
View ArticleAnswer by ThePhilosopher for How to delete history of last 10 commands in shell?
to delete last 10 entries (based on your example) :history -d 511 520
View ArticleAnswer by Alex for How to delete history of last 10 commands in shell?
Maybe will be useful for someone.When you login to any user of any console/terminal history of your current session exists only in some "buffer" which flushes to ~/.bash_history on your logout.So, to...
View ArticleAnswer by Bryant Bernstein for How to delete history of last 10 commands in...
Combining answers from above:history -wvi ~/.bash_historyhistory -r
View ArticleAnswer by steveo'america for How to delete history of last 10 commands in shell?
A simple function can kill all by number (though it barfs on errors)kill_hist() { for i in $(echo $@ | sed -e 's/ /\n/g;' | sort -rn | sed -e 's/\n/ /;') do history -d $i; done}kill_hist `seq 511 520`#...
View ArticleAnswer by Wasef Anwar for How to delete history of last 10 commands in shell?
for h in $(seq $(history | tail -1 | awk '{print $1-N}') $(history | tail -1 | awk '{print $1}') | tac); do history -d $h; done; history -d $(history | tail -1 | awk '{print $1}')If you want to delete...
View ArticleAnswer by user6280539 for How to delete history of last 10 commands in shell?
history -c will clear all histories.
View ArticleAnswer by JGC for How to delete history of last 10 commands in shell?
My answer is based on previous answers, but with the addition of reversing the sequence so that history items are deleted from most recent to least recent.Get your current history (adjust the number of...
View ArticleAnswer by Ghassan Zein for How to delete history of last 10 commands in shell?
First, type: history and write down the sequence of line numbers you want to remove.To clear lines from let's say line 1800 to 1815 write the following in terminal:$ for line in $(seq 1800 1815) ; do...
View ArticleAnswer by Barmar for How to delete history of last 10 commands in shell?
for x in `seq $1 $2`do history -d $1done
View ArticleAnswer by Tyler Jandreau for How to delete history of last 10 commands in shell?
edit:Changed the braced iterators, good call. Also, call this function with a reverse iterator.You can probably do something like this:#!/bin/bashHISTFILE=~/.bash_history # if you are running it in a #...
View ArticleAnswer by WheretheresaWill for How to delete history of last 10 commands in...
Have you tried editing the history file directly:~/.bash_history
View ArticleHow to delete history of last 10 commands in shell?
Commands follows 511 clear 512 history 513 history -d 505 514 history 515 history -d 507 510 513 516 history 517 history -d 509 518 history 519 history -d 511 520 historyI can delete single one by...
View ArticleAnswer by Gabriel Staples for How to delete history of last 10 commands in...
How to delete unwanted history entries in your shell...or even edit or add entries.Quick summary# check your shell's cached historyhistory# force-write the cached history to the `~/.bash_history`...
View Article