Shell scripting Common (1)

Source: Internet
Author: User
Tags case statement

\u indicates that the current user name \h represents the machine name \w represents the base name of the current working directory \w represents the full path to the current working directory. $, $, $, $: $ The name of this shell file refers to the first one passed to the shell program The parameter "$" refers to the second parameter, "$" refers to the third parameter $# the number of arguments in the shell command $*, [email protected]: All parameters in the shell command $?: The return value after the shell command or shell program executes or the fallback A status value, which is an integer between 0~255

string comparison operators

= or = = Determine if two strings are equal!       = Determine whether two strings do not want to wait < left string in the ASCII table before the order of the right string, can only be used in [[]] in the > and < effect, can only be used for [[]]-Z string is empty-n string is non-null note: The string comparison operator does not exist ">=" or "<="



Integer comparison logical expression

-eq means that equals-ne represents not equal to-LT representation less than-GT represents greater than-le means less than or equal to-ge means greater than or equal to the above operator can be used for (()) and [[]], with spaces on both sides of the comparison expression and on both sides of the comparison operator. If used for [[]], be aware that there are spaces on both sides of the logical expression and on both sides of the comparison operator. If Used (()), you do not have to leave a blank. Mathematical comparison operators are not available in addition to = and!=,[]. in [[]], two types of numeric comparison operators are available. You can only use =,! =, <, >, >=, <= in (()), and you cannot use the first type of comparison operator.



File judgment and comparison logical expressions

-e file exists-F normal file (not directory or device file)-S is not empty file-D file is directory-H link file-r to current file user readable-W to current file user writable-X to current file user can execute-o current user as file The owning master-nt such as F1-nt F2 represents a file F1 than F2 new-ot such as f1-nt F2 means file F1 than F2 old



If a variable is assigned a string that contains spaces, use double quotation marks when using the variable in [], and not in [[]].


Compound of multiple logical expressions

-A or && is indicated with-O or | |           Express or!            Non-operators use-A,-O 、!. in [] You cannot use parentheses to enclose logical expressions to form complex logical expressions, and you can use the form of \ (\) to perform complex operations of logical expressions using $ (()).    Use &&, | |, in [[]] and (()) You can use parentheses && and | | Examples can be used between two pairs []: [1-LT 2] && [3-GT 4]



Case Statement--syntax

Case expression invalue1) action1;; value2) Action2;; ... *) action;;        esac* represents any arbitrary character? Represents an arbitrary character [] that represents a range of values, a pipe character that represents a logical OR











Shell scripting Common (1)

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.