test命令-linux shell 脚本
#!/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" #输出文件的权限 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |