Saturday 2 January 2016

Hadoop: mv: move files from one HDFS location to other HDFS locaiton

“mv” command is used to move files from one HDFS location to other HDFS location. internally it will not move the data, it just change the directory structure.

Usage:
hadoop fs [generic options] -mv <src> ... <dst>
 
Example
hadoop fs -mv /user/cloudera/demo1/a.txt /user/cloudera/demo1/info.txt /user/cloudera/demo3
 
Above snippet move the files a.txt, info.txt to the folder demo3.


$hadoop fs -ls /user/cloudera/demo1
Found 6 items
-rw-r--r--   1 cloudera cloudera          2 2022-03-22 23:58 /user/cloudera/demo1/a.txt
-rw-r--r--   1 cloudera cloudera    6166736 2022-03-22 23:57 /user/cloudera/demo1/atlas.docx
-rw-r--r--   1 cloudera cloudera    9147128 2022-03-22 23:57 /user/cloudera/demo1/atlasClient.docx
-rw-r--r--   1 cloudera cloudera    6988969 2022-03-22 23:58 /user/cloudera/demo1/gradle.docx
-rw-r--r--   1 cloudera cloudera       2539 2022-03-23 21:10 /user/cloudera/demo1/info.txt
-rw-r--r--   1 cloudera cloudera    8986359 2022-03-22 23:58 /user/cloudera/demo1/maven.docx
$
$hadoop fs -ls /user/cloudera/demo3
$
$hadoop fs -mv /user/cloudera/demo1/a.txt /user/cloudera/demo1/info.txt /user/cloudera/demo3
$
$hadoop fs -ls /user/cloudera/demo1
Found 4 items
-rw-r--r--   1 cloudera cloudera    6166736 2022-03-22 23:57 /user/cloudera/demo1/atlas.docx
-rw-r--r--   1 cloudera cloudera    9147128 2022-03-22 23:57 /user/cloudera/demo1/atlasClient.docx
-rw-r--r--   1 cloudera cloudera    6988969 2022-03-22 23:58 /user/cloudera/demo1/gradle.docx
-rw-r--r--   1 cloudera cloudera    8986359 2022-03-22 23:58 /user/cloudera/demo1/maven.docx
$
$
$hadoop fs -ls /user/cloudera/demo3
Found 2 items
-rw-r--r--   1 cloudera cloudera          2 2022-03-22 23:58 /user/cloudera/demo3/a.txt
-rw-r--r--   1 cloudera cloudera       2539 2022-03-23 21:10 /user/cloudera/demo3/info.txt


Previous                                                 Next                                                 Home

No comments:

Post a Comment