我在常见的Linux文件系统中知道du -sh
。但是如何使用HDFS做到这一点呢?
发布于 2015-02-18 21:51:04
hadoop fs -du -s -h /path/to/dir
以可读的形式显示目录的大小。
发布于 2016-06-24 19:43:55
这样你就可以得到GB大小了
hdfs dfs -du PATHTODIRECTORY | awk '/^[0-9]+/ { print int($1/(1024**3)) " [GB]\t" $2 }'
发布于 2018-07-24 21:37:51
当尝试计算目录中特定文件组的总数时,-s
选项不起作用(在Hadoop2.7.1中)。例如:
目录结构:
some_dir
├abc.txt
├count1.txt
├count2.txt
└def.txt
假设每个文件的大小为1 KB。您可以使用以下命令汇总整个目录:
hdfs dfs -du -s some_dir
4096 some_dir
然而,如果我想要包含"count“的所有文件的总和,该命令就不能满足要求。
hdfs dfs -du -s some_dir/count*
1024 some_dir/count1.txt
1024 some_dir/count2.txt
为了解决这个问题,我通常通过awk传递输出。
hdfs dfs -du some_dir/count* | awk '{ total+=$1 } END { print total }'
2048
https://stackoverflow.com/questions/6504107
复制相似问题