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" #输出文件的权限


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM