Re: delete ~ directory

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

 



On Tue, Apr 20, 2004 at 03:10:19AM +0900, d l wrote:
> 
> As far as i know if u use brace to qoute a char/string,
> bash will not tries to expand/subsitute it.
> 
> so in your case 
> 
> rm -rf '~'
> 
> should work

Watch out for hints that "should work".  ;-)

When in doubt make a dummy user account with no privileges and 
play with the problem.

What I would try in my dummy account is:
     cd ~
     mkdir BigJunkPile
     mv -i ./'~'  BigJunkPile
     ls -ld BigJunkPile
     ls -l  BigJunkPile   # is my bad boy dir there.
     rm -ri BigJunkPile

 or

     cd ~
     mkdir BigJunkPile
     mv -i ./'~'  BigJunkPile/TwiddleJunk
     ls -ld BigJunkPile
     ls -l  BigJunkPile   # is my bad boy dir there should be called TwiddleJunk
     rm -ri BigJunkPile

The key with file names that contain meta characters of any kind is to
find a safe place to tinker and RTFM.  In this case the bash man page
has a number of paragraphs on Tilde Expansion.  Here is one:

   "Tilde Expansion
       "If  a  word  begins  with an unquoted tilde character (â~â), all of the
       characters preceding the first unquoted slash (or  all  characters,  if
       there  is no unquoted slash) are considered a tilde-prefix.  If none of
       the characters in the tilde-prefix are quoted, the  characters  in  the
       tilde-prefix  following the tilde are treated as a possible login name.
       If this login name is the null string, the tilde is replaced  with  the
       value  of  the shell parameter HOME.  If HOME is unset, the home direc-
       tory of the user executing the shell is  substituted  instead.   Other-
       wise,  the  tilde-prefix is replaced with the home directory associated
       with the specified login name.
       .... 
and more

BTW: both work....

    [BoxA]$ ls
    Desktop  evolution  Gorp  mail  Mail  mbox  SELinux
    [BoxA]$ mkdir '~'
    [BoxA]$ cd '~'
    [BoxA[BoxAch bark tree grass bugs
    [BoxAbark  bugs  grass  tree
    [BoxA[BoxA]$ cd ~
    [BoxA]$ ls
    ~  Desktop  evolution  Gorp  mail  Mail  mbox  SELinux
    [BoxA]$      cd ~
    [BoxA]$      mkdir BigJunkPile
    [BoxA]$      mv -i ./'~'  BigJunkPile
    [BoxA]$      ls -ld BigJunkPile
    drwxrwxr-x  3 BoxA Apr 19 14:06 BigJunkPile
    [BoxA]$      ls -l  BigJunkPile
    total 8
    drwxrwxr-x  2 BoxA Apr 19 14:05 ~
    [BoxA]$
    [BoxA]$ ls
    BigJunkPile  Desktop  evolution  Gorp  mail  Mail  mbox  SELinux
    [BoxA]$ cd '~'
    -bash: cd: ~: No such file or directory
    [BoxA]$ mkdir '~'
    [BoxA]$ cd '~'
    [BoxA]$ ls
    [BoxA]$ touch bark tree grass bugs
    [BoxA]$ cd
    [BoxA]$ mv BigJunkPile/ BigJunkPile1
    [BoxA]$ ls
    ~  BigJunkPile1  Desktop  evolution  Gorp  mail  Mail  mbox  SELinux
    [BoxA]$ cd ~
    [BoxA]$ mkdir BigJunkPile
    [BoxA]$ mv -i ./'~'  BigJunkPile/TwiddleJunk
    [BoxA]$ ls -ld BigJunkPile
    drwxrwxr-x  3 BoxA Apr 19 14:08 BigJunkPile
    [BoxA]$      ls -l  BigJunkPile
    total 8
    drwxrwxr-x  2 BoxA Apr 19 14:07 TwiddleJunk
    [BoxA]$ ls
    BigJunkPile  BigJunkPile1  Desktop  evolution  Gorp  mail  Mail  mbox  SELinux
    [BoxA]$
    [BoxA]$ rm -ri BigJunkPile
    rm: descend into directory `BigJunkPile'? y
    rm: descend into directory `BigJunkPile/TwiddleJunk'? y
    rm: remove regular empty file `BigJunkPile/TwiddleJunk/bark'? y
    rm: remove regular empty file `BigJunkPile/TwiddleJunk/tree'? y
    rm: remove regular empty file `BigJunkPile/TwiddleJunk/grass'? y
    rm: remove regular empty file `BigJunkPile/TwiddleJunk/bugs'? y
    rm: remove directory `BigJunkPile/TwiddleJunk'? y
    rm: remove directory `BigJunkPile'? y
    [BoxA]$ rm -ri BigJunkPile1/
    rm: descend into directory `BigJunkPile1/'? y
    rm: descend into directory `BigJunkPile1//~'? y
    rm: remove regular empty file `BigJunkPile1//~/bark'? y
    rm: remove regular empty file `BigJunkPile1//~/tree'? y
    rm: remove regular empty file `BigJunkPile1//~/grass'? y
    rm: remove regular empty file `BigJunkPile1//~/bugs'? y
    rm: remove directory `BigJunkPile1//~'? y
    rm: remove directory `BigJunkPile1/'? y
    [BoxA]$


-- 
	T o m  M i t c h e l l 
	/dev/null the ultimate in secure storage.



[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux