I want to copy files from HDFS. I want folders to be excluded while copying files. I tried hdfs dfs -copyToLocal
but it also copies directories as I tested.
Is there any way/command to copy files but not directories?
A variant of @daemon12's answer that achieves the same thing.
hadoop fs -ls <HDFS_DIR_PATH> | grep "^-" | \
awk '{print $8'} | hadoop fs -copyToLocal $(xargs) .
awk '{print $8'}
is used to obtain the actual path column from ls
output.$(xargs)
is used to concatenate lines of paths into space separated string.