歡迎您光臨本站 註冊首頁

shell編程中test命令

←手機掃碼閱讀     火星人 @ 2014-03-26 , reply:0

我剛接觸linux正學到shell編程if命令(以前沒接觸過編程),書上有個查看文件屬性的代碼我不是很明白特來請教
原文如下
#!/bin/bash
#4.10.sh
if test -z $1
then echo 'please input a file name'
else
if test -w $1
then echo "writeable"
else
echo "unwriteable"
fi
if test -x $1
then echo "excuteable"
else
echo "unexcuteable"
fi
fi
上面的意思不是test命令測試沒有輸入文件名時的時候輸出please input a file name
那下面不應該是測試文件不可寫時輸出writeable
我的理解上是不是錯了,在哪裡?
體諒一下自學的痛苦,麻煩各位。

[火星人 ] shell編程中test命令已經有286次圍觀

http://coctec.com/docs/linux/show-post-183491.html