Wednesday 23 March 2022

Hadoop: copyToLocal: Copy folder from hdfs to local system

“copyToLocal” command is used to copy a folder from HDFS to local system.


Usage
hadoop fs [generic options] -copyToLocal [-p] [-ignoreCrc] [-crc] <src> ... <localdst>
 
Example
hadoop fs -copyToLocal /user/cloudera/demo4 ./copyToLocalDemo
 

Above snippet copy the folder '/user/cloudera/demo4' from HDFS to your system folder 'copyToLocalDemo'.

$hadoop fs -ls /user/cloudera/demo4/
Found 3 items
-rw-r--r--   1 cloudera cloudera          2 2022-03-23 09:03 /user/cloudera/demo4/a.txt
-rw-r--r--   1 cloudera cloudera         35 2022-03-23 09:03 /user/cloudera/demo4/b.txt
-rw-r--r--   1 cloudera cloudera         55 2022-03-23 09:03 /user/cloudera/demo4/c.txt
$
$mkdir copyToLocalDemo
$
$ls ./copyToLocalDemo/
$
$hadoop fs -copyToLocal /user/cloudera/demo4 ./copyToLocalDemo
$
$ls ./copyToLocalDemo/
demo4
$
$ls ./copyToLocalDemo/demo4/
a.txt  b.txt  c.txt

 


 

Previous                                                 Next                                                 Home

No comments:

Post a Comment