The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to remove a directory with special characters in it??

Discussion in 'General Discussion' started by aarondwyer, Dec 18, 2010.

  1. aarondwyer

    aarondwyer Well-Known Member

    Joined:
    Mar 26, 2005
    Messages:
    73
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Brisbane
    cPanel Access Level:
    Root Administrator
    Hi

    How can I remove a directory using SSH that is like this ...


    w\034g,\260\207(\315\361\2340\230\035\235\030\201\035/



    Aaron
     
  2. aapkapratik

    aapkapratik Member

    Joined:
    Oct 26, 2009
    Messages:
    24
    Likes Received:
    0
    Trophy Points:
    1
    Hello,


    If you are too sure about removing the folder with name

    w\034g,\260\207(\315\361\2340\230\035\235\030\201\035/

    Please use following command

    Make sure you use the double quotes like this "" at the beginning and end of the folder name you wish to remove.

    Please be sure while using the command rm -rf as this will remove folder and all the files within the folder recursively and forcefully ( without asking for your permission )
     
  3. aarondwyer

    aarondwyer Well-Known Member

    Joined:
    Mar 26, 2005
    Messages:
    73
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Brisbane
    cPanel Access Level:
    Root Administrator
    Thanks for your help.

    Yes, I had tried that technique and it didn't work. The directory isn't budging.

    Aaron
     
  4. kernow

    kernow Well-Known Member

    Joined:
    Jul 23, 2004
    Messages:
    865
    Likes Received:
    9
    Trophy Points:
    18
    cPanel Access Level:
    Root Administrator
    Try renaming the dir and then deleting it.
     
  5. aarondwyer

    aarondwyer Well-Known Member

    Joined:
    Mar 26, 2005
    Messages:
    73
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Brisbane
    cPanel Access Level:
    Root Administrator
    Tried to rename it this is what I got.

    Code:
    mv "w\034g,\260\207(\315\361\2340\230\035\235\030\201\035" test
    mv: cannot stat `w\\034g,\\260\\207(\\315\\361\\2340\\230\\035\\235\\030\\201\\035': No such file or directory
    
    Code:
    cd "w\034g,\260\207(\315\361\2340\230\035\235\030\201\035"
    -bash: cd: w\034g,\260\207(\315\361\2340\230\035\235\030\201\035: No such file or directory
    
    Code:
    ls -la
    drwxr-xr-x    2 root     root      1024 Dec 16  2006 w\034g,\260\207(\315\361\2340\230\035\235\030\201\035/
    
    Any ideas? This one has me beat.

    I don't even know what's in there or how it got created.


    Aaron
     
  6. kernow

    kernow Well-Known Member

    Joined:
    Jul 23, 2004
    Messages:
    865
    Likes Received:
    9
    Trophy Points:
    18
    cPanel Access Level:
    Root Administrator
    its probably reading the quotes.
    Remove the quotes and just do
    Code:
    mv w\034g,\260\207(\315\361\2340\230\035\235\030\201\035 test
     
  7. aarondwyer

    aarondwyer Well-Known Member

    Joined:
    Mar 26, 2005
    Messages:
    73
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Brisbane
    cPanel Access Level:
    Root Administrator
    No go, still won't budge.

    Code:
    mv w\034g,\260\207(\315\361\2340\230\035\235\030\201\035 hello
    -bash: syntax error near unexpected token `('
    Thanks
    Aaron
     
  8. kernow

    kernow Well-Known Member

    Joined:
    Jul 23, 2004
    Messages:
    865
    Likes Received:
    9
    Trophy Points:
    18
    cPanel Access Level:
    Root Administrator
    Try this one, cd to the dir containing the crappy dir name, then:
    Code:
    rename -n 's/[;?|\\]//(g'  newname
    The above should rename any dir with any of the special characters to newname
     
    #8 kernow, Dec 20, 2010
    Last edited: Dec 20, 2010
  9. aarondwyer

    aarondwyer Well-Known Member

    Joined:
    Mar 26, 2005
    Messages:
    73
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Brisbane
    cPanel Access Level:
    Root Administrator
    Hi Kernow

    Sorry but that doesn't even give me any error messages.

    The command just runs and returns me to the prompt.

    The directory is still there.

    Any other ideas?

    Aaron
     
  10. kernow

    kernow Well-Known Member

    Joined:
    Jul 23, 2004
    Messages:
    865
    Likes Received:
    9
    Trophy Points:
    18
    cPanel Access Level:
    Root Administrator
    Hmmm............... OK try it with the s switch:
    Code:
    rename -s 's/[;?|\\]//(g'  newname
     
  11. cPanelRobin

    cPanelRobin Registered

    Joined:
    Mar 24, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    You can try removing the dir(or file) knowing its inode number.

    ls -il *

    145197508 drwxr-xr-x 3 root root 4096 Dec 22 07:08 w\\034g,\\260\\207(\\315\\361\\2340\\230\\035\\235\\030\\201\\035/

    find . -inum 145197508 -exec rm -rf {} \;

    This should help. Please note that first field is the inode number from "ls -il *" command.
     
Loading...

Share This Page