#!/bin/bash
usage="$0 Usage: xx [days]"
if [ ! "$1" ]
then
echo $usage
exit 1
fi
now=$(date +%s)
./hadoop fs -ls -r xxxx路径 | while read f; do
#取文件串中的日期信息
dir_date=`echo $f | awk '{print $6}'`
difference=$(( ( $now - $(date -d "$dir_date" +%s) ) / (24 * 60 * 60 ) ))
if [ $difference -gt $1 ]; then
#echo $f;
dir=`echo $f | awk '{print $8}'`
echo $dir >> ./toDelete.txt;
./hadoop fs -rm -r $dir;
fi
done