hdfs 文件名空格
I got this error when I tried to save a file with a space in its name into 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 ...
显式设置它。
翻译自: https://www.systutorials.com/how-to-put-files-with-spaces-in-names-into-hdfs/
hdfs 文件名空格