HDFS is a distributed file system designed to run on top of the local file system. Many times we may need to copy files from different sources i.e. from the internet, remote network, or from the local file system. There are "CopyFromLocal" and "Put" commands to help us in performing the task. While copying a file from the local file system to HDFS, if the file exists in the destination, the execution will fail and we will receive 'the file exists' error.
Let's assume the file "emp.txt" already exists in the path /user/cloudera.
Hadoop fs -put Desktop/emp.txt /user/cloudera/emp.txt
Hadoop fs -copyFromLocal Desktop/emp.txt /user/cloudera/emp.txt
Hadoop fs -copyFromLocal -f Desktop/Documents/emp.txt /user/cloudera/emp.txt
This is succeeded. The file is copied to the destination without any errors.
The usage of the "-f" option with -copyFromLocal will overwrite the destination if it already exists.
No comments:
Post a Comment