81

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.

General Grievance
  • 4,555
  • 31
  • 31
  • 45
java_dev
  • 992
  • 1
  • 8
  • 11
  • It's not the comma, it's the space character beind it. Placing your argument inside quotes will help. – rsp Nov 23 '12 at 15:36
  • yes @rsp there was space too after comma, i have used the following command to delete this directory successfully "hadoop dfs -rmr hdfs://host:port/Navi/MyDir\,\ Name" it works. – java_dev Nov 24 '12 at 05:41
  • The `\` in the command line escape the comma (unnecessary) and the space. Using quotes will escape any character needed, both will work. – rsp Nov 24 '12 at 09:25

9 Answers9

96

Have you tried :

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

HISI
  • 4,557
  • 4
  • 35
  • 51
gega
  • 984
  • 7
  • 3
79

Or if you dont know the url, you can use

hadoop fs -rm -r -f /user/the/path/to/your/dir
prasun
  • 7,073
  • 9
  • 41
  • 59
Jeyhun Karimov
  • 1,295
  • 19
  • 27
24
hdfs dfs -rm -r /path/to/directory
koders
  • 5,654
  • 1
  • 25
  • 20
9

Run the command in the terminal

$hadoop fs -rm -r /path/to/directory
Arefe
  • 11,321
  • 18
  • 114
  • 168
5

In hadoop1.0:

hadoop fs -rmr /PATH/ON/HDFS

In hadoop2.0:

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

Use \ to escape , in path

Ani Menon
  • 27,209
  • 16
  • 105
  • 126
4

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.

prasun
  • 7,073
  • 9
  • 41
  • 59
user2531037
  • 126
  • 3
2

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

prasun
  • 7,073
  • 9
  • 41
  • 59
Akarsh
  • 389
  • 5
  • 15
1
$ hadoop fs -rmdir {directory_name}
prasun
  • 7,073
  • 9
  • 41
  • 59
Candice
  • 181
  • 5
1

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.