脚本:
#!/bin/bash
for file in $(ls /home)
do
if
[ -L "$file" ]
then
echo "$file is lianjie";
elif [ -d "$file" ]
then
echo "$file is mulu";
elif [ -f "$file" ]
then
echo "$file is putong";
elif [ -S "$file" ]
then
echo "$file is socket";
else
echo "$file is qita";
fi
done
运行结果:
abc is qita
cde is qita
jp is qita
ls -l 查看结果
-rwxr-xr-x. 1 root root 0 6月 23 05:30 abc
lrwxrwxrwx. 1 root root 3 6月 23 05:30 cde -> abc
drwxr-xr-x. 2 root root 4096 6月 23 05:30 jp
慕斯6215715
angie