Shell脚本判断是文件还是目录怎么写?
发布网友
发布时间:2022-04-23 05:04
我来回答
共1个回答
热心网友
时间:2022-04-12 14:33
#!/bin/bash
if [ -d $1 ]
then
echo "$1 is a directory."
exit
elif [ -f $1 ]
then
echo -n "$1 is a file, "
if [ -L $1 ]
then
echo "and it is also a symbolic link."
A=`ls -L $1`
if [ -e $A ]
then
echo "Symbolic link exist."
else
echo "Symbolic link not exist."
fi
exit
else
echo "but it is not a symbolic link."
exit
fi
fi