delete all files but do not delete any directory

来源:互联网 发布:什么软件打字最快 编辑:程序博客网 时间:2024/05/22 12:03
#!/bin/bash
myfunc()
{
        for x in $(ls)
        do
                if [ -f "$x" ];then
                        echo "$x is file";
                        rm -rf "$x";
                elif [ -L "$x" ];then
                        echo "this is a link";
                else
                        echo "$x is directory";
                        cd "$x";
                        myfunc;
                        cd ..
                fi
        done
}
cd /home/www/mall/templates
myfunc

原创粉丝点击