阅读内容

Linux的文件处理挺强挺厉害

[日期:2008-09-05] 来源:Linux社区  作者:Linux


在Linux下写了一个删除不含有我们修改标记以及空文件夹的脚本。确实很好用,代码行也很少。赞一个。

1. del file

#!/bin/sh
# -------- I contain myself so i will not be deleted ----

# ------------ del file start ---------------------


#for file in $(grep -R -L -i FOMA08-1st *)
for file in $(grep -R -L -i F8_1ST *)
do
echo $file
rm -f $file
done
# ------------ del file end ---------------------


2 del folder

QUOTE:
#!/bin/sh
# ------------ I contain FOMA08-1st and F8_1ST ---------------------
# ----------------- del dir without file start---------------


path=$(pwd)
echo "$path"
oldNum="1"
newNum="0"
while [ "$oldNum" -ne "$newNum" ]
do
oldNum="`find | wc -l`"

for dir in $(find)
do
if [ -d $dir ]
then
if [ "`ls -al $dir | wc -l`" -gt "3" ]
then
echo
#echo " file exist"
else
echo "$dir"
echo " del it, because it does not contain any file"
rm -rf $dir
fi
fi
done

newNum="`find | wc -l`"
done
# ----------------- del dir without file end---------------




相关资讯       linux编程  Linux教程 
本文评论       全部评论
发表评论
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款


点评: 字数
姓名:

L
I
N
U
X


GOOGLE搜索
Google