> On Mon, Sep 19, 2011 at 08:38:44AM -0400, Greg Wooledge wrote: >On Sun, Sep 18, 2011 at 10:11:17PM -0800, Roger wrote: >> > 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 > >> >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) > >Why not try running the code before you claim it doesn't work? Here, >written out in a more traditional-looking format: > >gawk ' >{ > c = $0 > getline > if ($1 != "rm") { > print c > print > } >} >' > >Does that make it easier to read?
Just got time to test and am amazed it works better then I expected, even after trying to trace the script. $ diff .bash_history.test .bash_history.gawk 1,2d0 < #1315341860 < rm test It caught the above 'rm' test statement I inserted and also left alone all "maildirmake" commands. However, it missed the lines with " rm " in the middle. (ie. blah blah command; rm bleh; command blah) No matter though, the GAwk snippet is posted and verified for others trying to purge rm from their history. They can now do so without clearing their whole history. I've done some minimal research on the history of GAwk/Awk and understand it's powerful, and how it recently had it's code optimized. Then GNU Manuals are great reads on the Kindle DXG, and will likely be studying GAwk next. -- Roger http://rogerx.freeshell.org/