#创建文件
#!/bin/bash
now_path=`pwd`
echo "当前目录为:" $now_path
read -p "输入文件名" filepath
if [ ! -e $now_path/$filepath ]
then
touch $now_path/$filepath
else
echo "file is exist!"
fi
查看文件权限
#查看文件权限
#!/bin/bash
now_path=`pwd`
read -p "输入文件名: " filename
filepath=$now_path/$filename
echo "当前文件为: " $filepath
if [ -e $filepath ]
then
if [ -r $filepath ]
then
echo "文件可读"
fi
if [ -w $filepath ]
then
echo "文件可写"
fi
if [ -x $filepath ]
then
echo "文件可运行"
fi
else
echo "file not exist!"
fi
修改文件权限
#修改文件权限
now_path=`pwd`
read -p "请输入要修改的文件名" filename
filepath=$now_path/$filename
echo $filepath
if [ -e $filepath ]
then
echo "您要修改权限的文件为:" $filepath
read -p "输入权限" power
if [ -n $power ]
then
if [[ $power = *x* ]]
then
chmod +x $filepath
fi
if [[ $power = *w* ]]
then
chmod +w $filepath
fi
if [[ $power = *r* ]]
then
chmod +r $filepath
fi
else
echo "is null! please input again!"
fi
else
echo "file not exist! you should create the file!"
fi