[Linux-disciples] delete a whole lot of files
Adam Rosi-Kessel
adam at rosi-kessel.org
Thu Feb 8 14:37:13 EST 2007
On 2/8/2007 2:31 PM, Stephen R Laniel wrote:
>> It is a little curious that this worked when rm ~/*.jpg didn't, but all's well
>> that ends well
> The answer is that when you do
> rm ~church/jpgs/*
> the shell expands '*' before 'rm' sees it. So the shell
> expands that to something like
> rm ~church/jpgs/1 ~church/jpgs/2 ~church/jpgs/3 ...
> Now, if '*' expands to many thousands of files, you've got a
> command line that's many thousands of characters long. Which
> is why bash complains.
In other words, globbing is always done by the shell, rather than the
application. This is also why, unlike in MS-DOS, rm doesn't give you
some warning if you do rm * (or del *.* as in DOS). rm doesn't even know
you typed *; it just gets the list of files that bash has already
substituted for the wildcard. A key advantage to this is that all
applications glob the same way, since they aren't doing the globbing
themselves.
More information about the Linux-disciples
mailing list