1 Star 0 Fork 0

findroot / shell-test

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
if.sh 659 Bytes
一键复制 编辑 原始数据 按行查看 历史
findroot 提交于 2016-06-23 18:51 . 增加一些测试
#! /bin/bash
if [ "$1" = "start" ];then
echo "start"
elif [ "$1" = "stop" ];then
echo "stop"
else
echo "error"
fi
#判断文件是否存在
if [ -f "$2" ];then
echo "file: "$2
else
echo "file error"
fi
#判断文件是否具有可执行权限
if [ -x "$2" ];then
echo "can exec"
else
echo "no exec"
fi
#判断文件是否具有可写权限
if [ -w "$2" ];then
echo "can write"
else
echo "no write"
fi
#判断文件大小是否为0(即文件是否为空)
if [ -s "$2" ];then
echo "NULL file"
else
echo "no null file"
fi
#判断是否为目录
if [ -d "$2" ];then
echo "is dir"
else
echo "no dir"
fi
Shell
1
https://gitee.com/findroot/test-shell.git
git@gitee.com:findroot/test-shell.git
findroot
test-shell
shell-test
master

搜索帮助