shell - How to copy files with spaces in filenames from Unix to HDFS without renaming or loops? - Stack Overflow

I have a large number of files (tens of thousands) in a Unix directory that I need to copy to Hadoop us

I have a large number of files (tens of thousands) in a Unix directory that I need to copy to Hadoop using the command:

hdfs dfs -put * /hdfs_folder/

However, some of these files have spaces in their filenames, such as "hello world.csv" or "this file has spaces.csv", and those fail during the transfer when using the wildcard approach.

Could you recommend a reliable method to copy all the files from Unix to HDFS that does not require renaming the files or using shell loops?

I’ve tried the following approaches, but none of them worked:

find . -type f -print0 | xargs -0 -I {} hdfs dfs -put "{}" /hdfs_folder/

find . -type f -exec hdfs dfs -put -f "{}" /hdfs_folder/ \;

printf '%s\0' "$folder_unix"/* | xargs -0 stat --format='%n' | awk -F/ -v basepath="$folder_unix" '{ printf "%s%c", basepath "/" $NF, 0 }' | xargs -0 hdfs dfs -put -f "${hdfs_folder}"

Any suggestions would be greatly appreciated.

Moving files with spaces in the name from Unix to a Hadoop folder

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744351159a4569983.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信