4917
5879
3万
GROAD
曲径通幽,安觅芳踪。
[beyes@localhost ~]$ test 9 -gt 8;echo $? 0 [beyes@localhost ~]$ test 9 -gt 10;echo $? 1 [beyes@localhost ~]$ test -d $HOME ; echo $? 0
[beyes@localhost ~]$ test 9 -gt 10 && echo True || echo false false [beyes@localhost ~]$ test 9 -gt 8 && echo True || echo false True
[beyes@localhost ~]$ [ "hello" != "world" ]; echo $? 0
-eq、 -ne、-lt、 -le、 -gt、 -ge 分别表示等于、不等于、小于、小于等于、大于、大于等于。
[beyes@localhost ~]$ [ "abc" = "abc" ]; echo $? [beyes@localhost ~]$ [ "abc" = "def" ]; echo $? 1 0
[beyes@localhost ~]$ [ "abc" \> "def" ]; echo $? 1 [beyes@localhost ~]$ [ "gabc" \> "defz" ]; echo $? 0 [beyes@localhost ~]$ [ "gabc" \< "xefz" ]; echo $? 0
[beyes@groad.net ~]$ string="hello" [beyes@groad.net ~]$ if [ -n "$stringer" ]; then echo hello world; fi [beyes@groad.net ~]$ if [ -n "$string" ]; then echo hello world; fi hello world
[beyes@localhost ~]$ mkdir shell [beyes@localhost ~]$ touch FILE1 [beyes@localhost ~]$ ln FILE1 FILE2 [beyes@localhost ~]$ [ FILE1 -ef FILE2 ]; echo $? 0
[beyes@localhost syscall]$ ll fork vfork -rwxrwxr-x. 1 beyes beyes 5663 May 26 19:47 fork -rwxrwxr-x. 1 beyes beyes 5673 May 27 05:48 vfork [beyes@localhost syscall]$ [ fork -nt vfork ]; echo $? 1
[beyes@localhost syscall]$ ll fork vfork -rwxrwxr-x. 1 beyes beyes 5663 May 26 19:47 fork -rwxrwxr-x. 1 beyes beyes 5673 May 27 05:48 vfork [beyes@localhost syscall]$ [ fork -ot vfork ]; echo $? 0
[beyes@localhost syscall]$ [ 9 -gt 8 -a 10 -gt 9 ]; echo $? 0 [beyes@localhost syscall]$ [ 9 -gt 8 -a 10 -gt 11 ]; echo $? 1
[beyes@localhost syscall]$ [ 9 -gt 8 -o 10 -gt 11 ]; echo $? 0
[beyes@localhost syscall]$ [ \( "a" = "$HOME" -o 3 -lt 4 \) ]; echo $? 0 [beyes@localhost syscall]$ [ ! \( "a" = "$HOME" -o 3 -lt 4 \) ]; echo $? 1
[beyes@localhost syscall]$ [ ! \( "a" = "b" -o '(' 3 -lt 4 ")" ")" ]; echo $? 1 [beyes@localhost syscall]$ [ ! \( "a" = "b" -o '(' 3 -lt 4 ')' ")" ]; echo $? 1
[beyes@localhost ~]$ set -o noglob [beyes@localhost ~]$ [ -o noglob ]; echo $? 0 [beyes@localhost ~]$ set +o noglob [beyes@localhost ~]$ [ -o noglob ]; echo $? 1
使用道具 举报
本版积分规则 发表回复 回帖后跳转到最后一页
小黑屋|手机版|Archiver|曲径通幽 ( 琼ICP备11001422号-1|公安备案:46900502000207 )
GMT+8, 2024-5-15 17:39 , Processed in 0.080216 second(s), 23 queries .
Powered by Discuz! X3.2
© 2001-2013 Comsenz Inc.