删除除了某一天外其他日期文件的sh脚本

#!/bin/sh
ls -l |while read line
do
month=`echo $line|awk '{print $6}'`
day=`echo $line|awk '{print $7}'`
#time=echo $line|awk '{print $8}'`
file=`echo $line|awk '{print $9}'`
if [ "$month" = "Jan" -a "$day" = "1" ]
then
continue
else
rm $file
echo "rm $file Ok!"
fi
done

source: http://www.unixsky.org/docs/linux/

Comments are closed.