[英]Hadoop FileSystem - How to delete all files that are of zero size in a given hdfs directory?
I have a hdfs directory A in the path: /user/A 我在路径中有一个hdfs目录A:/ user / A
How do I delete all files within A that are of zero size? 如何删除A中所有大小为零的文件?
Deleting only files: 仅删除文件:
hdfs dfs -rm $(hdfs dfs -ls -R /user/A/ | grep -v "^d" | awk '{if ($5 == 0) print $8}')
Test what you get first, since there are lots of HDFS formats, that may have metadata or files with 0 byte sizes (like parquet ..SUCCESS, ..TEMPORARY etc.) 测试您首先获得的内容,因为存在许多HDFS格式,其中可能包含元数据或字节大小为0的文件(例如镶木地板..SUCCESS,.. TEMPORARY等)
hdfs dfs -ls -R /user/A/ | grep -v "^d" | awk '{if ($5 == 0) print $8}'
这可能会有所帮助
hdfs dfs -ls -R /path/to/directory/ | grep part- | awk '{ if ($5 == 0) print $8 }' | xargs hdfs dfs -rm
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.