Quantcast
Channel: How to delete history of last 10 commands in shell? - Stack Overflow
Browsing latest articles
Browse All 22 View Live

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 Article



Answer 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 Article

Answer 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 Article

Answer 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 Article

Answer 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 Article


Answer 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 Article

Answer 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 Article

Answer 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 Article


Answer 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 Article


Answer 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 Article

Answer 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 Article

Answer 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 Article

Answer by Bryant Bernstein for How to delete history of last 10 commands in...

Combining answers from above:history -wvi ~/.bash_historyhistory -r

View Article


Answer 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 Article

Answer 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 Article


Answer by user6280539 for How to delete history of last 10 commands in shell?

history -c will clear all histories.

View Article

Answer 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 Article


Answer 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 Article

Answer by Barmar for How to delete history of last 10 commands in shell?

for x in `seq $1 $2`do history -d $1done

View Article

Answer 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 Article

Answer by WheretheresaWill for How to delete history of last 10 commands in...

Have you tried editing the history file directly:~/.bash_history

View Article


How 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 Article

Browsing latest articles
Browse All 22 View Live




Latest Images