平時(shí)項(xiàng)目不注意清理無用文件痕钢,占用空間越來越多萝勤。
小工具:shell刪除Java項(xiàng)目中的target/、.idea/优训、*.iml猎贴,支持遞歸刪除腻豌、支持mac系統(tǒng)。
vim clear.sh
賦值粘貼如下內(nèi)容
#!/bin/bash
function getdir(){
for element in `ls -a $1`
do
dir_or_file=$1"/"$element
if [ -d $dir_or_file ]
then
#過濾mac中.和..文件夾
if [ . != $element ] && [ .. != $element ]
then
if [ .idea == $element ] || [ target == $element ]
then
rm -rf $dir_or_file
else
getdir $dir_or_file
fi
fi
else
if [ ${element##*.} == iml ]
then
rm $dir_or_file
fi
fi
done
}
root_dir="./"
getdir $root_di
運(yùn)行
sh clear.sh