HDFS error: target already exists

I am very new to Hadoop. When I try to execute this command, it says that the target already exists. How to delete this file from hadoop? Is it the same as deleting a target?

me$ hdfs -copyFromLocal myfile.txt input/myfile.txt

copyFromLocal: Target input/myfile.txt already exists
+4
source share
4 answers

You do not need to delete the file first and then copy the new one. You can do this in one step using the option -fwith-copyFromLocal

hadoop fs -copyFromLocal -f myfile.txt input/myfile.txt
+3
source

If you want to delete a file with HDFS, you must do the following:

$ hadoop dfs -rm <filePath>

In your case, you need to:

$ hadoop dfs -rm input/myfile.txt
0
source

.

hadoop dfs -rmr <aDirectory>

rm -rf aDirectory linux

0

Mapreduce 2.x :

hadoop fs -rm /path/to/filename

-r, (, MR). , -rmr .

hadoop fs -rm -r /path/to/files

You can add the -skipTrash flag if you delete a large set of files and do not want them to sit until garbage collection occurs.

hadoop fs -rm -r -skipTrash /path/to/files
0
source

All Articles