First knowledge of the shell

Source: Internet
Author: User
A shell script is a special application that acts as a "command interpreter" between the operating system kernel and the user, takes care of the user input commands and interprets them, passes the required actions to the kernel execution, and outputs the execution results.
1. REDIRECT Operation
Input: < output: > Append: >> (a special kind of output) Error output:2> mixed output:&>


2 Pipe Operation: | Usually the result of the command output on the left is entered as the right command, and multiple pipelines can be used in the same row.

3. Operation of numeric variables:
Addition Operation: +
Subtraction Operations:-
Multiplication Operation: *
Division Operation:/
Residual operation:%

4. Pre-defined variables:
$#: Indicates the number of positional parameters in the command line
$*: Indicates the number of all positional parameters
$?: Indicates the return state after the previous command was executed
$ A: Represents the name of the currently executing script or program

5. File test:
-D: Test for Directory
-E: Test whether the directory or file exists
-F: Test for file
-R: Tests whether the current user has permission to read
-W: Tests whether the current user has permission to write
-X: Test whether the executable permission is set

6. Integer value comparison:
-eq: equals-ne: Not equal to-GT: greater than-lt: less than-le: less than or equal to-ge: greater than or equal to

7. String comparison:
=: The first character is the same as a second character
! =: The first character differs from the second character
-Z: Check if string is empty

8. Logic Test:
&&: Logical and, expressed and
|| : Logical OR, indicating or
! : Logical no, means no

First knowledge of the shell

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.