[will@localhost ShellScript]$ cat testfile.sh
#!/bin/sh
read -p "Input a filename : " filename
test -z $filename && echo "You MUST input a filename." && exit 0
test ! -e $filename && echo "The filename $filename DO NOT exist" && exit 0
test -f $filename && filetype="regulare file"
test -d $filename && filetype="directory"
test -r $filename && perm="r"
test -w $filename && perm=$perm"w"
test -x $filename && perm=$perm"x"
echo "The filename: $filename is a $filetype"
echo "And the permission are : $perm"
[will@localhost ShellScript]$
沒有留言:
張貼留言