...making Linux just a little more fun!

2-Cent Tips

2-cent tip: A safer 'rm'

Ben Okopnik [ben at linuxgazette.net]

Sun, 16 May 2010 08:49:40 -0400

----- Forwarded message from "Silas S. Brown" <ssb22 at cam.ac.uk> -----

If you've ever tried to delete Emacs backup files with

rm *~

(i.e. remove anything ending with ~), but you accidentally hit Enter before the ~ and did "rm *", you might want to put this in your .bashrc and .bash_profile :

function rm () { if test "a $*" == "a $(echo *)"; then echo "If you really meant that, say -f" else /bin/rm $@; fi }

That way, typing "rm *" will give you a message telling you to use the -f flag if you really meant it, but any other rm command will work. (The "a" in the test is to ensure that any options for "rm" are not read as options for "test".)

(It's also possible to alias rm to rm -i, but that's more annoying as it prompts EVERY time, which is likely to make you habitually type -f and that could be a bad thing.)


----- End forwarded message -----

[ Thread continues here (8 messages/14.88kB) ]

2-cent Tip: Message splitter

Ben Okopnik [ben at linuxgazette.net]

Sun, 9 May 2010 15:15:29 -0400

Once in a while, I need to split a mailbox (a.k.a. an mbox-formatted file) into individual messages. This time, I've come up with a solution that's going to go into my "standard solutions" file; it works well, and saves the messages in zero-padded numerical filenames, so that they're even properly sorted in the filesystem. Enjoy!

awk '{if (/^From /) f=sprintf("%03d",++a);print>>f}' mail_file

-- * Ben Okopnik * Editor-in-Chief, Linux Gazette * http://LinuxGazette.NET *

2 cent tip: Screenshot with a pull-down menu

Prof. Partha [profdrpartha at gmail.com]

Tue, 4 May 2010 19:44:24 -0400

You can do it with our good old GIMP. Go to the screen you want, click and get that drop down menu. Launch GIMP. The go to File > Acquire > Screenshot. Set delay to, say, 10 sec. Minimise GIMP and bring up the screen with your desired pull down menu. GIMP will make a snapshot of the screen in 10 sec.

I have uploaded a screen shot made this way, just for you to check out if this is what you want. See http://www.profpartha.webs.com/snap2.jpg .

Have fun.

Dr. S. Parthasarathy              |   mailto:profdrpartha at gmail.com
Algologic Research & Solutions    |
78 Sancharpuri Colony, Bowenpally |   Phone: + 91 - 40 - 2775 1650
Secunderabad 500 011 - INDIA      |


Talkback: Discuss this article with The Answer Gang

Copyright © 2010, . Released under the Open Publication License unless otherwise noted in the body of the article. Linux Gazette is not produced, sponsored, or endorsed by its prior host, SSC, Inc.

Published in Issue 175 of Linux Gazette, June 2010