hdfs 文件名空格_如何将带有空格的文件放入HDFS?

hdfs 文件名空格

I got this error when I tried to save a file with a space in its name into HDFS:

尝试将名称中带有空格的文件保存到HDFS时出现此错误

$ hdfs dfs -put -f "/home/u1/testa/test a" "/u1/testa/test a"
put: unexpected URISyntaxException

while the HDFS seems allow spaces in its file names: https://hadoop.apache.org/docs/r2.7.3/hadoop-project-dist/hadoop-common/filesystem/model.html .

而HDFS似乎在其文件名中允许使用空格: https : //hadoop.apache.org/docs/r2.7.3/hadoop-project-dist/hadoop-common/filesystem/model.html

How to achieve the effect of saving the files with spaces in its names into HDFS?

如何达到将名称中带有空格的文件保存到HDFS中的效果?

A tip to help you save a file with spaces in its name into HDFS: putting file from STDIN. One example is as follows:

帮助您将名称中带有空格的文件保存到HDFS中的提示:将文件从STDIN放入。 一个示例如下:

date | hdfs dfs -put - "/path/file with space.txt"

For your example above, the command can be:

对于上面的示例,命令可以是:

cat "/home/u1/testa/test a" | hdfs dfs -put -f - "/u1/testa/test a"

Then your file will be save into HDFS successfully with the space kept.

然后,您的文件将在保留空间的情况下成功保存到HDFS中。

Note that if you would like to keep the mode of the file, you will need to set it explicitly using hdfs dsf -chmod ....

请注意,如果要保留文件的模式,则需要使用hdfs dsf -chmod ...显式设置它。

Answered by zma.
由zma回答。

翻译自: https://www.systutorials.com/how-to-put-files-with-spaces-in-names-into-hdfs/

hdfs 文件名空格

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值