Shell Common Criteria for judging

Source: Internet
Author: User

1, determine if the folder existsif[-d/home/q/www];then Echo"true";ElseEcho"false"; Fi (folder exists in the system/home/q/www)2, determine whether the file existsif[-E/ETC/PASSWD];then Echo"true";ElseEcho"false"; Fiif[-F/ETC/PASSWD];then Echo"true";ElseEcho"false"; fi file exists and size greater than 0if[-S/ETC/PASSWD];then Echo"true";ElseEcho"false"; Fi3, judge the document to be readableif[-R/ETC/PASSWD];then Echo"true";ElseEcho"false"; Fi4, judgment file can be writtenif[-W/ETC/PASSWD];then Echo"true";ElseEcho"false"; Fi5, judging file executableif[-X/ETC/PASSWD];then Echo"true";ElseEcho"false"; Fi6, string length is 0, return true length is 0if[-Z""];then Echo"true";ElseEcho"false"; fi length is not 0if[-Z"Xiaoqiang"];then Echo"true";ElseEcho"false"; Fi7, string length is not 0, return true length not 0if[-N"Xiaoqiang"];then Echo"true";ElseEcho"false"; Fi length is 0if[-N""];then Echo"true";ElseEcho"false"; Fi8, judging the string equalityif["Xiaoqiang"="Xiaoqiang"];then Echo"true";ElseEcho"false"; Fi9, judge the string is not equalif["Xiaoqiang"!="Xiaoqiang"];then Echo"true";ElseEcho"false"; FiTen, judging the equality of integersif[1-eq1];then Echo"true";ElseEcho"false"; Fi One, judging that integers are not equalif[1-ne1];then Echo"true";ElseEcho"false"; Fi A, judging integers1<2if[1-lt2];then Echo"true";ElseEcho"false"; Fi -, judging integers2<=2if[2-le2];then Echo"true";ElseEcho"false"; Fi -, judging integers 3 >2if[3-gt2];then Echo"true";ElseEcho"false"; Fi the, judging integers3>=3if[3-ge3];then Echo"true";ElseEcho"false"; Fi -, logical operation! (non)if[ !3-ge3];then Echo"true";ElseEcho"false"; Fi-A (and)if[-Z""-A3-ge3];then Echo"true";ElseEcho"false"; Fi-O (OR)if[-Z"SADFSA"-O3-ge3];then Echo"true";ElseEcho"false"; Fi -, special variable echo"number:$#"get the number of parameters echo"scname:$0"get the script name Echo"first:$1"gets the first parameter of Echo"second:$2"get the second parameter echo"Argume:[email protected]"get all parameters echo"show Parm list: $*"Listecho of data parameters"Show Process ID: $$"Get Process Idecho"show Precomm stat:$?"Gets the result of the command execution

Shell Common Criteria for judging

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.