I am looking for a command in hadoop 2.x to delete files which are Zero bytes in hdfs. Can any one please let me know appropriate command. I am trying to find the files that has are of zero bytes in hdfs and delete them from the directory.
for f in $(hdfs dfs -ls -R / | awk '$1 !~ /^d/ && $5 == "0" { print $8 }'); do hdfs dfs -rm "$f"; done
Step by step:
hdfs dfs -ls -R /
- list all files in HDFS recursively
awk '$1 !~ /^d/ && $5 == "0" { print $8 }')
- print full path of those being not directories and with size 0
for f in $(...); do hdfs dfs -rm "$f"; done
- iteratively remove
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With