DragonFly kernel List (threaded) for 2008-02
DragonFly BSD
DragonFly kernel List (threaded) for 2008-02
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

Re: Globbing


From: Oliver Fromme <check+jw9s6d00rssc8bjn@xxxxxxxxxx>
Date: 15 Feb 2008 08:01:34 GMT

Bill Hacker wrote:
 > The *original* task was to delete all files in a single subdir.
 > 
 > Regardless.
 > 
 > But w/o panicing a running IMAP daemon that might want to add a few new 
 > ones during the process.
 > 
 > It was, after all, a Maildir/.Trash folder..

echo * | xargs rm

That's what I've been using in such cases for 15 years.
Works in every shell.  (Do not use it in world-writable
directories, though; it can be exploited.  But the same
is true for "rm *", too.)

You can, of course, put Simon's xrm() shell function in
your shell startup script (I was about to suggest a
similar function, but Simon beat me to it).  You can
even call it rm so you can type "rm *" and it'll handle
any size of arguments.

The only problem is that you need to remember it when
you're logged into a machine where you don't have that
function.  And when writing (portable) shell scripts,
of course.

Another problem is that that function solves the problem
for rm only.  You would need similar functions for grep,
sed, cat, tail and so on.  The xargs solution is generic
because it can be combined with every tool, so it's more
in the spirit of UNIX.

Best regards
   Oliver

-- 
Oliver Fromme, secnetix GmbH & Co. KG, Marktplatz 29, 85567 Grafing b. M.
Handelsregister: Registergericht Muenchen, HRA 74606,  Geschäftsfuehrung:
secnetix Verwaltungsgesellsch. mbH, Handelsregister: Registergericht Mün-
chen, HRB 125758,  Geschäftsführer: Maik Bachmann, Olaf Erb, Ralf Gebhart

FreeBSD-Dienstleistungen, -Produkte und mehr:  http://www.secnetix.de/bsd



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