Re [Gllug] rm -R not working on Fedora
Daniel P. Berrange
dan at berrange.com
Fri Feb 11 20:44:24 UTC 2005
On Fri, Feb 11, 2005 at 08:34:59PM +0000, Garry Heaton wrote:
>
> For example, I enter a directory in which I own all the files and files are
> 0644. I issue the command:
>
> rm -R *.php.bak
>
> Example 1
> All the '.php.bak' files within the current directory are removed but none
> within the subdirectories, despite having the same file permissions.
The wildcards get expanded by your shell before being passed to 'rm'. So
if you have foo.php.bak in the current directory, then the above command
will expand to:
rm -R foo.php.bak
To avoid this, you need to quote the arguments:
rm -R '*.php.bak'
> Example 2
> I enter my home diretory and issue these commands:
>
> mkdir exdir
> cd exdir
> touch file1.txt
> mkdir subdir
> cd subdir
> touch file2.txt
> cd ..
> rm -R *.txt
>
> Result: file1.txt is removed but file2.txt remains
When, you are in 'exdir' your command expands to
rm -R file1.txt
Which obviously won't match 'subdir/file2.txt', so again
you need to quote the command
rm -R '*.txt'
Regards,
Dan.
--
|=- GPG key: http://www.berrange.com/~dan/gpgkey.txt -=|
|=- Perl modules: http://search.cpan.org/~danberr/ -=|
|=- Projects: http://freshmeat.net/~danielpb/ -=|
|=- berrange at redhat.com - Daniel Berrange - dan at berrange.com -=|
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 240 bytes
Desc: not available
URL: <http://mailman.lug.org.uk/pipermail/gllug/attachments/20050211/2ae2834c/attachment.pgp>
-------------- next part --------------
--
Gllug mailing list - Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug
More information about the GLLUG
mailing list