我试图这样做hdfs dfs -pwd
,但该命令不存在.所以目前我诉诸干什么hdfs dfs -ls ..
其次hdfs dfs -ls ../..
.
我也查看了命令列表,hdfs dfs
但没有看到任何看起来很有希望的东西.
有没有更直接的方法来找到绝对路径?
"hdfs dfs -pwd"不存在,因为当您从命令行运行命令时,HDFS中没有"工作目录"概念.
你不能在HDFS shell中执行"hdfs dfs -cd",然后从那里运行命令,因为HDFS shell和"hdfs dfs -cd"命令都不存在,因此使工作目录的想法变得多余.
您的主目录始终是路径的前缀,除非它从"/"开始.
如果要查看主目录的绝对路径,可以创建一个空目录并将其删除,该信息可以显示绝对路径.
[test@test ~]$ hadoop fs -mkdir t1 [test@test ~]$ hadoop fs -rm -r t1 17/02/14 10:00:46 INFO fs.TrashPolicyDefault: Namenode trash configuration: Deletion interval = 1 minutes, Emptier interval = 0 minutes. Moved: 'hdfs://nameservice1/user/test/t1' to trash at: hdfs://nameservice1/user/test/.Trash/Current
'hdfs:// nameservice1/user/test/t1'是t1目录的绝对路径
文件系统shell实用程序中没有等效的pwd
命令,但这是使用and 的解决方法: hdfs dfs
mkdir
find
$ hdfs dfs -mkdir xYz $ hdfs dfs -find / -name "xYz"
(其中“ xYz”是未使用的文件名)
在一个命令中:
$ echo $(dirname $(hdfs dfs -rm -R xYz>/dev/null 2>&1;hdfs dfs -mkdir xYz&&hdfs dfs -find / -name "xYz"))
没有-cd
命令,所以我猜你希望-pwd
返回主目录.
根据这个相关问题:HDFS主目录,hdfs的主目录总是/user/<ShortUserName>
(它在源代码中是硬编码的).
像unix/linux这样的hadoop中没有这样的PWD,CD支持.
可能的Hadoop命令是
-appendToFile -cat -checksum -chgrp -chmod -chown -copyFromLocal -copyToLocal -count -cp -createSnapshot -deleteSnapshot -df -du -expunge -get -getfacl -getfattr -getmerge -help -ls -mkdir -moveFromLocal -moveToLocal -mv -put -renameSnapshot -rm -rmdir -setfacl -setfattr -setrep -stat -tail -test -text -touchz -usage