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.
source share