bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Purge History of rm commands


From: Mike Frysinger
Subject: Re: Purge History of rm commands
Date: Mon, 19 Sep 2011 01:37:22 -0400
User-agent: KMail/1.13.7 (Linux/3.1.0-rc4; KDE/4.6.3; x86_64; ; )

On Monday, September 19, 2011 01:18:02 Roger wrote:
> I'm stumped on this as my history is in the format of:
> 
> $ tail ~/.bash_history
> #1316296633
> man bash
> #1316296664
> bash -xv
> #1316372056
> screen -rd
> #1316375930
> exit
> #1316392889
> exit
> 
> Is there a method of purging the history off all rm commands with such a
> file format?  I've tried using history | find | grep | sed, but the
> history doesn't accept more then one history command line number.

so put it into a for loop ?

> I'm guessing the next easiest method is to learn awk/gawk so I can edit the
> above .bash_history file.

gawk '{ c = $0; getline; if ($1 != "rm") { print c; print; } }' .bash_history

> The easiest method, just open the history file with VI/VIM and start
> deleting the 20 or so lines... which I'll likely start doing now. ;-)
> 
> ... or did I miss something?

i rarely use `history`, so i cant suggest any improvements there
-mike

Attachment: signature.asc
Description: This is a digitally signed message part.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]