- Subscribe to RSS Feed
- Mark Question as New
- Mark Question as Read
- Float this Question for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
How to copy files from HDFS recursive to the local file system
- Labels:
-
Apache Hadoop
Created ‎03-07-2019 04:42 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How we can copy recursive jar files from HDFS ( jar files are under sub folders ) to local folder?
Example
export hdfs_folder=/app/lib export local_folder=/home/work_app
while under /app/lib we have the following sub folder with the jar files
as
/app/lib/folder_jar1
/app/lib/folder_jar2
Under each of above folder we have jar files
The following command , will copy only the jar files under /app/lib
but not the Jar files under the sub folders as /app/lib/folder_jar1 , /app/lib/folder_jar2 , Etc
hadoop fs -copyToLocal $hdfs_folder/*.jar $local_folder
Created ‎03-08-2019 08:46 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You are specifying /folder/*.jar. If you want the .jar files from one level deeper, you would specify /folder/*/*.jar.
Or, here is an alternative example.
[hdfs@c2175-node4 stuff]$ hdfs dfs -find /tmp -name *.jar /tmp/somefolder/y.jar /tmp/x.jar [hdfs@c2175-node4 stuff]$ for result in `hdfs dfs -find /tmp -name *.jar` ; do hdfs dfs -copyToLocal $result; done [hdfs@c2175-node4 stuff]$ ls -al -rw-r--r-- 1 hdfs hadoop 0 Mar 8 08:43 x.jar -rw-r--r-- 1 hdfs hadoop 0 Mar 8 08:43 y.j
Created ‎03-08-2019 08:46 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You are specifying /folder/*.jar. If you want the .jar files from one level deeper, you would specify /folder/*/*.jar.
Or, here is an alternative example.
[hdfs@c2175-node4 stuff]$ hdfs dfs -find /tmp -name *.jar /tmp/somefolder/y.jar /tmp/x.jar [hdfs@c2175-node4 stuff]$ for result in `hdfs dfs -find /tmp -name *.jar` ; do hdfs dfs -copyToLocal $result; done [hdfs@c2175-node4 stuff]$ ls -al -rw-r--r-- 1 hdfs hadoop 0 Mar 8 08:43 x.jar -rw-r--r-- 1 hdfs hadoop 0 Mar 8 08:43 y.j
