[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to delete a file name?
From: |
David T-G |
Subject: |
Re: How to delete a file name? |
Date: |
Wed, 6 Nov 2002 12:04:47 -0500 |
User-agent: |
Mutt/1.4i |
Ding --
This isn't exactly a bug, but I can help you nonetheless...
...and then Ding guoqiang said...
%
% Dear sirs:
%
% There is a rubbish file name in my directory,which is "
% -la .signature", how to delete it? I have tried like
% these"rm ./ -la .signature",and"rm -- -la .signature",but these
% doings are useless..
% would you please tell me how to delete this dust
% rubbish file name?
Ah, the classic "I can't delete this because rm complains" problem :-)
Good job using the -- for the - at the beginning of the file, but that's
not enough. It looks like that's not actually the beginning of the file,
in fact; there seems to be a space at the front as well as the space
within.
You could just let rm walk through the list, though that can be hard in a
full directory. Something like
rm -i *
rm -i *signature*
rm -i ?-la*
with a 'no' response for everything except this file would do it. That's
just a workaround, though, that doesn't answer how to really take care of
the problem.
Your shell sees those spaces and thinks that they are word separators, so
you need to "escape" them, or remove their special meaning, and make them
just part of the file name. You can do this one character at a time with
the backslash (\) character, or you can wrap the whole filename in
quotes. Thus, you could also use
rm \ -la\ .signature
rm " -la .signature"
rm ' -la .signature"
to get the job done -- and, in fact, with commands other than rm such as
mv or vi. Note the difference between the single and double quotes; if
you had
file 1 foo
file 1 *
file 1 bar
and you only wanted to get rid of the middle one,
rm 'file 1 *'
is guaranteed to work while
rm "file 1 *"
might, in certain cases, have its * expanded and take the other two files
with it.
% Think you very much!
You're quite welcome. You owe the Oracle a decoding of the secret code
in the signature below (or a piece of fried chicken... yumm...).
%
% Sincerely yours
%
% Ding Guo Qiang
HTH & HAND
:-D
--
David T-G * There is too much animal courage in
(play) address@hidden * society and not sufficient moral courage.
(work) address@hidden -- Mary Baker Eddy, "Science and Health"
http://www.justpickone.org/davidtg/ Shpx gur Pbzzhavpngvbaf Qrprapl Npg!
pgpwJYfkrHuAP.pgp
Description: PGP signature