#!/bin/sh
#判断文件和文件夹是否存在
type=$1
name=$2
isCreate=$3
isDelete=$4
if [ "$type" = "0" ];
then
if [ -f $name ];
then
echo "file存在"
if [ $isDelete = "true" ];
then
rm $name
fi
else
echo "file不存在"
if [ $isCreate = "true" ];
then
touch $name
fi
fi
elif [ "$type" = "1" ];
then
if [ -d $name ];
then
echo "dir存在"
if [ $isDelete = "true" ];
then
rmdir $name
fi
else
echo "dir不存在"
if [ $isCreate = "true" ];
then
mkdir $name
fi
fi
fi