加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

test命令-linux shell 脚本

发布时间:2020-12-13 22:33:37 所属栏目:Linux 来源:网络整理
导读:#!/bin/bash # This is program will check you file name,which sys has or not,end print types. #2019/07/19? FSQ First release echo -e "input file name:" filename read filename test -z $filename echo "please input a file name" exit 0? #test -

#!/bin/bash

# This is program will check you file name,which sys has or not,end print types.

#2019/07/19? FSQ

First release

echo -e "input file name:" filename

read filename

test -z $filename && echo "please input a file name" && exit 0? #test -z 检查输入是否为空

test ! -e $filename && echo" $filename is not exsit" && exit 0 # test -e? 检查输入的文件是否存在

test -d $filename && filetype="regulare file" #检查文件的是否是目录

test -f $filename && filetype="directory" #检查文件是否常规文件

test -r $filename && perm="readable" #检查文件的执行状态 是否可读

test -w $filename && perm="$perm writeable" #检查文件的执行状态 是否可写

test -x $filename && perm="$perm? execute#检查文件是否 可执行

echo "The file name : $filename is a $filetype" #输出文件的类型

echo "And the permissions are :$perm" #输出文件的权限

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读