Hi, Carsten

rm protects itself.  You will get the message
        rm: cannot remove `.' or `..'
if you try to remove .* with "rm -rf .*".  Pity it's not documented.

Here's some code from fileutils-4.0/src/remove.c:

    788 enum RM_status
    789 rm (struct File_spec *fs, int user_specified_name,
                const struct rm_options *x)
    790 {
    791   mode_t filetype_mode;
    792
    793   if (user_specified_name)
    794     {
    795       char *base = base_name (fs->filename);
    796
    797       if (DOT_OR_DOTDOT (base))
    798         {
    799           error (0, 0, _("cannot remove `.' or `..'"));
    800           return RM_ERROR;
    801         }
    802     }

and here's the results of a rm -rf .* on that directory:

[root@rbh00 src]# pwd
/home/rbh00/src/fileutils-4.0/src
[root@rbh00 src]# rm -rf .*
rm: cannot remove `.' or `..'
rm: cannot remove `.' or `..'
[root@rbh00 src]#

HTH

Dick Hitt   [EMAIL PROTECTED]


> From [EMAIL PROTECTED] Thu Mar 21 14:10:14 2002
> X-X-Sender: [EMAIL PROTECTED]
> MIME-Version: 1.0
> X-Sender: [EMAIL PROTECTED]
> Approved-By:  Carsten Sommer <[EMAIL PROTECTED]>
> Date:         Thu, 21 Mar 2002 22:57:06 +0100
> From: Carsten Sommer <[EMAIL PROTECTED]>
> Subject:      mistake in movefs-howto
> To: [EMAIL PROTECTED]
>
> Hi all,
>
> I think there is a serious mistake in the movefs-howto on linuxvm.org.
> Section 8 says you should cd to /usr and execute "rm -rf * .*" to delete
> the contents of the old /usr directory. The problem is that ".*"  matches
> ".." too and would actually delete all files and directories under /. It
> would be the same as "rm -rf /". The /usr directory normally doesn't
> contain any dotfiles or dotdirs, so "rm -rf *" should be enough. To be on
> the safe side you could do "rm -rf /usr" and afterwards "mkdir /usr" to
> recreate the mountpoint.
>
> And I have a question too: It says you should use tar to copy. Is there a
> reason why I cannot use "cp -ax"? I have used "cp -ax" a few times to copy
> directories to other partitions and don't have experienced any problems.
>
> Regards
> Carsten
> --
> Carsten Sommer <[EMAIL PROTECTED]>
>

Reply via email to