永发信息网

求Linux shell编写

答案:1  悬赏:0  手机版
解决时间 2021-11-29 09:44
  • 提问者网友:战皆罪
  • 2021-11-28 16:46
求Linux shell编写
最佳答案
  • 五星知识达人网友:一秋
  • 2021-11-28 17:58
没有人答你这种幼稚问题吗?那我大慈大悲的告诉你好了:
#! /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]的文件类型。
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯