计算已删除的文件Shell脚本

时间:2013-02-05 22:53:15

标签: shell

您能告诉我如何计算您从文件夹中删除的扩展名“.txt”的文件? Unix中的Shell脚本

感谢您的回答:)

我试图以这种方式删除它们:

删除= 0

读取行时

if test -d "$line"
then

for i in "$line"/*
do


    if test -f "$i"
    then
    deleted=`ls -l $line |grep "*.o" | wc -l`
    echo "From: " $line " I deleted : " $deleted
    find . -type f -name "*.o" -exec rm -f {} \;

    else
    echo "Not file " $i                   
    fi

done

else
echo "NOT a directory!"
fi

完成

2 个答案:

答案 0 :(得分:1)

尝试这样做:

LANG=C rm -v *.txt | grep -c "^removed "

答案 1 :(得分:0)

答案 - 虽然不一定是正确答案:

files=*.txt
ls -1 "$files" | wc -l
rm "$files"

露丝

相关问题