没有人答你这种幼稚问题吗?那我大慈大悲的告诉你好了:
#! /bin/bash
if [ x$1 != x ];then
if [ ! -f "$1" ];then
echo "$1 is file"
elif [ ! -d "$1" ];then
echo "$1 is directory"
elif [ ! -b "$1" ];then
echo "$1 is block device"
elif [ ! -c "$1" ];
echo "$1 is character device"
elif [ ! -L "$1" ];then
echo "$1 is symbolic link"
else
echo "$1 is other file type!"
fi
else
echo "Useage:"
echo "./testfile [file name]"
fi
保存为testfile,然后chmod 766 testfile,在bash下执行
./testfile [file name]
就会返回[file name]的文件类型。