Shell Development notes

Source: Internet
Author: User

1. For and if commands containing [] must be separated by spaces.

2. Calculation and Assignment Methods

Var = 1 (Note: Bash/pdksh cannot leave spaces on both sides of the equal sign)

First: (VAR ++ ))

Type 2: var =$ ($ var + 1 ))

 

3. Judgment conditions:

[-F "somefile"]: determines whether it is a file.

[-X "/bin/ls"]: determines whether/bin/ls exists and has the executable permission.

[-N "$ Var"]: determines whether the $ var variable has a value.

["$ A" = "$ B"]: determines whether $ A and $ B are equal.

 

Int1-EQ int2 | returns true if int1 is equal to int2
Int1-ge int2 | returns true if int1 is greater than/equal to int2
Int1-Le int2 | returns true if int1 is smaller than/equal to int2
Int1-GT int2 | returns true if int1 is greater than int2
Int1-ne int2 | returns true if int1 is not equal to int2

 

If [$ res = "Y"-o $ res = "Y"] Where-O or,-A and

 

 

4. Common commands

 

4-1 grep query Filtering

4-2 awk text operation tool

Variable name meaning
Number of argc command line Variables
Argv command line meta Array
Filename current input file name
Number of records in the current FNR File
The input field delimiter of FS. The default Delimiter is a space.
RS input record delimiter
Number of domains in the current NF record
No. of NR records so far
OFS output domain Separator
ORS output record Separator

Root # ll | awk-F "" '{print NR, NF, $8}' are separated by a space and only 8th columns are displayed.

The output port 2001Program: Netstat-tunlp | grep 2001 | awk-F "'{print $7}' | awk-F"/"'{print $2 }'

 
 

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.