[Top][All Lists]

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

Re: Purge History of rm commands

From: Roger
Subject: Re: Purge History of rm commands
Date: Sun, 18 Sep 2011 22:11:17 -0800
User-agent: Mutt/1.5.21 (2010-09-15)

Hi fellow Gentooer.

> On Mon, Sep 19, 2011 at 01:37:22AM -0400, Mike Frysinger wrote:
>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

I don't know gawk (yet), but thinking this isn't going to step-up the one line
from the found 'rm' instance and omit the comment above it. (see above)

(I'm guessing gawk language is better for these complexities vs. sed.  As I
said, the GNU GAWK manual is next on my reading list.)

Also, there's plenty of residual uses of rm where I had to instruct regex grep
& sed to omit from it's results. (ie. maildirmake)

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

Ditto here too, but just taking time to exercise regex here.

In the end, I just went through and deleted them with VIM (and made sure

I also found I could push the history command line numbers individually in
reverse order to "history -d", but it didn't succeed.

(No biggy, just pinging the list as I didn't find anything on Google.)


reply via email to

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