Skip to content

Instantly share code, notes, and snippets.

@u2
Created December 17, 2013 12:49
Show Gist options
  • Save u2/8004430 to your computer and use it in GitHub Desktop.
Save u2/8004430 to your computer and use it in GitHub Desktop.
Shell遍历文件夹并删除匹配文件
#!/bin/sh
list_alldir(){
for file2 in `ls -a $1`
do
if [ x"$file2" != x"." -a x"$file2" != x".." ];then
if [ -d "$1/$file2" ] && (echo $file2 | grep -qv '.svn');then
list_alldir "$1/$file2"
elif (echo $1/$file2 | egrep -q '(de|el|fr|it)\.yml$');then
echo "$1/$file2"
rm $1/$file2
fi
fi
done
}
list_alldir $1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment