#!/bin/sh RM="rm -rf" function delete_all_dir() { for i in `ls` do if [ -d $i ];then $RM $i fi done } function delete_all_file() { for i in `ls` do if [ -f $i ];then $RM $i fi done } case $1 in f) delete_all_file ;; d) delete_all_dir ;; esac
用法:
删除文件夹 [root@192 Desktop]# ./test.sh d
删除文件 [root@192 Desktop]# ./test.sh f