How to Delete a directory from Hadoop cluster which is having comma(,) in its name?

FileHadoopComma

File Problem Overview


I have uploaded a Directory to hadoop cluster that is having "," in its name like "MyDir, Name" when I am trying to delete this Directory by using rmr hadoop shell command as following

hadoop dfs -rmr hdfs://host:port/Navi/MyDir, Name

I'm getting the following messages rmr: cannot remove hdfs://host:port/Navi/MyDir,: No such file or directory. rmr: cannot remove Name: No such file or directory.

However I have successfully deleted other Directories from the same location, using the same command i.e.

hadoop dfs -rmr hdfs://host:port/dir_path

any solutions to delete such kind of Directories.

File Solutions


Solution 1 - File

Have you tried :

hadoop dfs -rmr hdfs://host:port/Navi/MyDir\,\ Name?

Solution 2 - File

Or if you dont know the url, you can use

hadoop fs -rm -r -f /user/the/path/to/your/dir

Solution 3 - File

hdfs dfs -rm -r /path/to/directory

Solution 4 - File

Run the command in the terminal

$hadoop fs -rm -r /path/to/directory

Solution 5 - File

In hadoop1.0:

hadoop fs -rmr /PATH/ON/HDFS

In hadoop2.0:

hdfs dfs -rm -R /PATH/ON/HDFS

Use \ to escape , in path

Solution 6 - File

Here you can find all hadoop shell commands:

deleting: rmr Usage: hadoop fs -rmr URI [URI …]

Recursive version of delete.

Example:

hadoop fs -rmr /user/hadoop/dir
hadoop fs -rmr hdfs://nn.example.com/user/hadoop/dir

Exit Code:

Returns 0 on success and -1 on error.

Solution 7 - File

Try hadoop dfs -rm -r hdfs://host:port/Navi/MyDir\,\ Name now

Solution 8 - File

$ hadoop fs -rmdir {directory_name}

Solution 9 - File

Or you can: hadoop fs -rm -r PATH

Hint: if you enter: hadoop fs -rmr PATH you would mostly get:Please use 'rm -r' instead.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionjava_devView Question on Stackoverflow
Solution 1 - FilegegaView Answer on Stackoverflow
Solution 2 - FileJeyhun KarimovView Answer on Stackoverflow
Solution 3 - FileeaorakView Answer on Stackoverflow
Solution 4 - FileArefeView Answer on Stackoverflow
Solution 5 - FileAni MenonView Answer on Stackoverflow
Solution 6 - Fileuser2531037View Answer on Stackoverflow
Solution 7 - FileAkarshView Answer on Stackoverflow
Solution 8 - FileCandiceView Answer on Stackoverflow
Solution 9 - FileMoshih HsüView Answer on Stackoverflow