shell脚本——test命令练习
2026/4/9小于 1 分钟
shell脚本——test命令练习
#! /bin/bash
if [ $# -ne 1 ]
then
echo arguments not valid
exit 1
fi
if [ ! -e "$1" ]
then
echo not exist
exit 2
fi
if [ -f "$1" ]
then
echo regulare file
fi
if [ -d "$1" ]
then
echo directory
fi
if [ -r "$1" ]
then
echo readable
fi
if [ -w "$1" ]
then
echo writable
fi
if [ -x "$1" ]
then
echo executable
fi