Rename directory to hdfs

I need to rename the directory to hdfs. Which team is for this?

hadoop fs -mv <src> <dest> 

The above command moves the src folder to the dest folder. Instead, I want the src folder to be renamed to dest .

+6
source share
3 answers

Rename is not chaop, but you can move, hasoop fs -mv oldname newname

+9
source

I think you are missing a point in the mv command (linux / hdfs).

When the destination already exists, if it is a file, the error message mv: 'dest': File exists appears.
In the case of a directory, the source will go inside it. Thus, the command works acceptable, just try it with a non-existent dest.

Now, to solve this problem, you can use the hadoop test command and the OR short circuit for Linux.

 hadoop fs -test -e dest || hadoop fs -mv src dest 

If the directory does not exist, call mv . You can even go further:

 hadoop fs -rmr dest hadoop fs -mv src dest 

This file first deletes the dest file, and then performs the move action. if this is not your intention, use the previous solution.

+7
source

You can rename a folder in HDFS using the mv command

 hadoop fs -mv 'Old folder name with path' ' new folder name with path' 

Example: I have a folder in HDFS in the location /test/abc and I want to rename it to PQR

 hadoop fs -mv '/test/abc' '/test/PQR'; 

Results:

Rename folder to HDFS

0
source

Source: https://habr.com/ru/post/979088/


All Articles