{"id":4009,"date":"2019-07-21T23:37:41","date_gmt":"2019-07-21T15:37:41","guid":{"rendered":"https:\/\/www.linuxcool.com\/?p=4009"},"modified":"2019-07-23T01:08:42","modified_gmt":"2019-07-22T17:08:42","slug":"test","status":"publish","type":"post","link":"https:\/\/www.linuxcool.com\/test","title":{"rendered":"test\u547d\u4ee4 – \u68c0\u67e5\u6761\u4ef6\u662f\u5426\u6210\u7acb"},"content":{"rendered":"\n

test \u547d\u4ee4\u7528\u4e8e\u68c0\u67e5\u67d0\u4e2a\u6761\u4ef6\u662f\u5426\u6210\u7acb\uff0c\u5b83\u53ef\u4ee5\u8fdb\u884c\u6570\u503c\u3001\u5b57\u7b26\u548c\u6587\u4ef6\u4e09\u4e2a\u65b9\u9762\u7684\u6d4b\u8bd5\u3002 <\/p>\n\n\n\n

test \u547d\u4ee4\u671f\u671b\u5728\u547d\u4ee4\u884c\u4e2d\u627e\u5230\u4e00\u4e2a\u53c2\u6570\uff0c\u5f53 shell \u6ca1\u6709\u4e3a\u53d8\u91cf\u8d4b\u503c\u65f6\uff0c\u5219\u5c06\u8be5\u53d8\u91cf\u89c6\u4e3a\u7a7a\u3002\u8fd9\u610f\u5473\u7740\u5728\u5904\u7406\u811a\u672c\u65f6\uff0c\u4e00\u65e6\u811a\u672c\u5bfb\u627e\u7684\u53c2\u6570\u4e0d\u5b58\u5728\uff0c\u5219 test \u5c06\u62a5\u544a\u8be5\u9519\u8bef\u3002 <\/p>\n\n\n\n

\u8bed\u6cd5\u683c\u5f0f\uff1a<\/strong>test  [\u8868\u8fbe\u5f0f]<\/p>\n\n\n\n

\u5e38\u7528\u53c2\u6570\uff1a<\/strong><\/p>\n\n\n\n
-eq \uff08=\uff09<\/td>\u7b49\u4e8e\u5219\u4e3a\u771f <\/td><\/tr>
-ne \uff08\uff01=\uff09<\/td>\u4e0d\u7b49\u4e8e\u5219\u4e3a\u771f <\/td><\/tr>
-gt \uff08>\uff09<\/td>\u5927\u4e8e\u5219\u4e3a\u771f <\/td><\/tr>
-ge \uff08>=\uff09<\/td>\u5927\u4e8e\u7b49\u4e8e\u5219\u4e3a\u771f <\/td><\/tr>
-lt \uff08<\uff09<\/td>\u5c0f\u4e8e\u5219\u4e3a\u771f <\/td><\/tr>
-le \uff08<=\uff09<\/td>\u5c0f\u4e8e\u7b49\u4e8e\u5219\u4e3a\u771f <\/td><\/tr><\/tbody><\/table>\n\n\n\n

\u53c2\u8003\u5b9e\u4f8b<\/strong><\/p>\n\n\n\n

\u5224\u65ad\u4e24\u4e2a\u6570\u662f\u5426\u76f8\u7b49\uff1a<\/p>\n\n\n\n

[root@linuxcool ~]# \nnum1=100 \nnum2=100 \nif test $[num1] -eq $[num2] then     \necho '\u4e24\u4e2a\u6570\u76f8\u7b49\uff01' \nelse     \necho '\u4e24\u4e2a\u6570\u4e0d\u76f8\u7b49\uff01' \nfi <\/pre>\n\n\n\n

\u6bd4\u8f83\u4e24\u4e2a\u6570\u5927\u5c0f\uff1a<\/p>\n\n\n\n

[root@linuxcool ~]# \nnum1=101\nnum2=100 \nif test $[num1] -ge $[num2] then     \necho '\u4e24\u4e2a\u6570\u76f8\u7b49\uff01' \nelse     \necho '\u4e24\u4e2a\u6570\u4e0d\u76f8\u7b49\uff01' \nfi <\/pre>\n\n\n\n

\u5224\u65ad\u4e24\u4e2a\u5b57\u7b26\u4e32\u662f\u5426\u76f8\u7b49\uff1a<\/p>\n\n\n\n

[root@linuxcool ~]# \nnum1=\"W3Cschool\" \nnum2=\"W3Cschool\" \nif test num1=num2 then     \necho '\u4e24\u4e2a\u5b57\u7b26\u4e32\u76f8\u7b49!' \nelse     \necho '\u4e24\u4e2a\u5b57\u7b26\u4e32\u4e0d\u76f8\u7b49!' \nfi <\/pre>\n\n\n\n

\u5224\u65ad\u6587\u4ef6\u662f\u5426\u5b58\u5728\uff1a<\/p>\n\n\n\n

[root@linuxcool ~]# \ncd \/bin \nif test -e .\/bash then     \necho '\u6587\u4ef6\u5df2\u5b58\u5728!' else     \necho '\u6587\u4ef6\u4e0d\u5b58\u5728!' \nfi <\/pre>\n\n\n\n

\u53e6\u5916\uff0cShell\u8fd8\u63d0\u4f9b\u4e86\u4e0e( -a )\u3001\u6216( -o )\u3001\u975e( ! )\u4e09\u4e2a\u903b\u8f91\u64cd\u4f5c\u7b26\u7528\u4e8e\u5c06\u6d4b\u8bd5\u6761\u4ef6\u8fde\u63a5\u8d77\u6765\uff0c\u5176\u4f18\u5148\u7ea7\u4e3a\uff1a”!”\u6700\u9ad8\uff0c”-a”\u6b21\u4e4b\uff0c”-o”\u6700\u4f4e\u3002\u4f8b\u5982\uff1a <\/p>\n\n\n\n

[root@linuxcool ~]# \ncd \/bin \nif test -e .\/notFile -o -e .\/bash then     \necho '\u6709\u4e00\u4e2a\u6587\u4ef6\u5b58\u5728!' else     \necho '\u4e24\u4e2a\u6587\u4ef6\u90fd\u4e0d\u5b58\u5728' \nfi <\/pre>\n","protected":false},"excerpt":{"rendered":"

test \u547d\u4ee4\u7528\u4e8e\u68c0\u67e5\u67d0\u4e2a\u6761\u4ef6\u662f\u5426\u6210\u7acb\uff0c\u5b83\u53ef\u4ee5\u8fdb\u884c\u6570\u503c\u3001\u5b57\u7b26\u548c\u6587\u4ef6\u4e09\u4e2a\u65b9\u9762\u7684\u6d4b\u8bd5\u3002 test \u547d\u4ee4\u671f\u671b\u5728\u547d\u4ee4\u884c […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[11],"tags":[],"_links":{"self":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts\/4009"}],"collection":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/comments?post=4009"}],"version-history":[{"count":6,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts\/4009\/revisions"}],"predecessor-version":[{"id":4136,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts\/4009\/revisions\/4136"}],"wp:attachment":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/media?parent=4009"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/categories?post=4009"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/tags?post=4009"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}