Benjamin Pflugmann wrote:


Like you think you're in /mnt/windows/My\ Documents\Downloads and you want to delete a bunch of junk directories with names like ???sefdljvn5+5, ???fdsre8344 etc., so you type "rm -Rf ./?*" Just after you hit Enter you realise that (a) you were in /usr and (b) "?" is a regular expression.

Minor nitpit: You mean shell pattern / globbing. Most shells don't
understand regular expressions. If it was a regular expression, "?"
would make the "/" optional and "*" would repeat that 0-n times, so
".", "./", ".//", ".///", etc. would match.
Damn, I've been spending too much time in Perl (which also globs, but in which "?" is also a regexp for substitution and interpolation (which I also tend to get mixed up). Hold on ... regexps interpolate, globs substitute. Or was it subs regulate, regglobs expulate, or ...
Btw, at least bash and tcsh support a nice feature. When your cursor
is at the end of the pattern, press "^X-*" (that is: press and hold
CTRL and press x, then let go of CTRL, press * - that is: SHIFT-8 for
american keyboard, I think). This will expand the pattern in-line and
you can see without hitting return, which files match.

I never use rm together with patterns without this trick anymore and
never have deleted a file accidently since then (quite some years...).

Nice trick - didn't know about that one. There again, it was years before I stumbled on Ctrl-U and Ctrl-D.

Sir Robin

--
" Like these cutters, and hackers, who will take the wall of men, and picke quarrells."
- G. Pettie

Robin Turner
IDMYO
Bilkent Univeritesi
Ankara 06533
Turkey

www.bilkent.edu.tr/~robin



Want to buy your Pack or Services from MandrakeSoft? 
Go to http://www.mandrakestore.com

Reply via email to