常用Linuxのif判定文
1890 ワード
常用Linuxのif判断文パラメータまとめ:最も一般的なフォーマット:if[-x xxxx]x代表パラメータ
ヒント:必要なパラメータを検索して使用
[ -a FILE ] FILE 。
[ -b FILE ] FILE 。
[ -c FILE ] FILE 。
[ -d FILE ] FILE 。
[ -e FILE ] FILE 。
[ -f FILE ] FILE 。
[ -g FILE ] FILE SGID 。
[ -h FILE ] FILE 。
[ -k FILE ] FILE 。
[ -p FILE ] FILE (F O) 。
[ -r FILE ] FILE 。
[ -s FILE ] FILE 0 。
[ -t FD ] FD 。
[ -u FILE ] FILE SUID (set user ID) 。
[ -w FILE ] FILE FILE 。
[ -x FILE ] FILE 。
[ -O FILE ] FILE ID 。
[ -G FILE ] FILE 。
[ -L FILE ] FILE 。
[ -N FILE ] FILE and has been mod ied since it was last read 。
[ -S FILE ] FILE 。
[ FILE1 -nt FILE2 ] FILE1 has been changed more recently than FILE2, or FILE1 exists and FILE2 does not 。
[ FILE1 -ot FILE2 ] FILE1 FILE2 , FILE2 FILE1 。
[ FILE1 -ef FILE2 ] FILE1 FILE2 。
[ -o OPTIONNAME ] shell “OPTIONNAME” 。
[ -z STRING ] “STRING” 。
[ -n STRING ] or [ STRING ] “STRING” non-zero 。
[ STRING1 == STRING2 ] 2 。 “=” may be used instead of “==” for strict POSIX compliance 。
[ STRING1 != STRING2 ] 。
[ STRING1 STRING2 ] “STRING1” sorts after “STRING2” lexicographically in the current locale 。
[ ARG1 OP ARG2 ] “OP” is one of -eq, -ne, -lt, -le, -gt or -ge. These arithmetic binary operators return true if “ARG1” is equal to, not equal to, less than, less than or equal to, greater than, or greater than or equal to “ARG2”, respectively. “ARG1” and “ARG2” are integers.
ヒント:必要なパラメータを検索して使用