Search code examples
shellhadoopcommandput

Can I transfer files within HDFS using -put command?


Hadoop documentation says- PUT-Copy single src, or multiple srcs from local file system to the destination file system

copyFromLocal - Similar to put command, except that the source is restricted to a local file reference.

Does it mean for -PUT source is NOT restricted to a local file reference and I can transfer files from HDFS to HDFS?

I did try this but could not success...

Please help , I am a complete newbie to Hadoop


Solution

  • Type this in terminal:

    hdfs dfs -put /user/new/sample.txt /user/new1/sample.txt
    

    This command will copy the file named sample.txt from hdfs directory /user/new to /user/new1. This is how you can copy a file to another location within HDFS.

    EDITED:

    hdfs dfs -cp /user/new/sample.txt /user/new1/sample.txt
    

    This command will also copy files within HDFS.