filecheck

来自「Advanced Bash&#8722 Scripting Guide An 」· 代码 · 共 37 行

TXT
37
字号
#!/bin/ksh# Scriptname: filecheck# Example 10.92# Usage: filecheck filename# Purpose: Check to see if a file exists,what type it is,# and its permissionsif [[ $# = 0 ]] ; then    print "Usage:  $(basename $0)  filename " 1>&2    exit 1fifile=$1	  # Variable is set to first command line argumentif [[ ! -a $file ]]then    print "$file does not exist"    exit 1fiif [[ -d $file ]] then    print "$file is a directory" elif [[ -f $file ]]then     if [[ -r $file && -w $file && -x $file ]]   # nested if command    then 	print "You have read, write, and execute permission on 	file $file"    else	print "You don't have the correct permissions"	exit 2    fielse    print "$file is neither a file nor a directory. "    exit 3fi

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?