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

aarondwyer

Well-Known Member
Verifed Vendor
Mar 26, 2005
73
0
156
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
 

aapkapratik

Member
Oct 26, 2009
24
0
51
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

# ll

This will List the information about the FILEs/FOLDERS in the current directory.

# rm -rf "w\034g,\260\207(\315\361\2340\230\035\235\030\201\035"
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 )
 

aarondwyer

Well-Known Member
Verifed Vendor
Mar 26, 2005
73
0
156
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
 

aarondwyer

Well-Known Member
Verifed Vendor
Mar 26, 2005
73
0
156
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
 

aarondwyer

Well-Known Member
Verifed Vendor
Mar 26, 2005
73
0
156
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
 

kernow

Well-Known Member
Jul 23, 2004
1,018
61
178
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
 
Last edited:

aarondwyer

Well-Known Member
Verifed Vendor
Mar 26, 2005
73
0
156
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
 

RobinT.

Registered
Mar 24, 2010
1
1
51
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.
 
  • Like
Reactions: Nick Hartman