Shell Learning Notes (i)

Source: Internet
Author: User

1.

1) Integer calculation:

(1)

$ (()): for mathematical calculations

echo $ ((3+3))

(2)

Expr: There must be spaces on either side of the operator, if $[] is included, you do not have to consider whitespace issues

Expr 2 + 2


2) floating point calculation:

BC for calculating floating-point numbers

Bc-q

Echo ' "3.44*5" |BC '


2. Defining arrays

x= (1 2 4 100 5)

X[3] = 20

(1) Output all echo ${x[*]}


(2) Number of output arrays:

${#x [*]}

${#x [@]}


(3) array element substitution:

Echo ${X[@]/100/3}

3.

(Variable name = variable name + constant/variable)

(variable name **n): The n-th-square of a variable

unset variable name: Delete variable

Unset X[0]


4. Generate random numbers, use $$ as placeholders

Random = $$

Echo $Random


5. Time Performance Comparison

Time echo {1,100}

Time Echo SEQ 100

Time SEQ 100


6.

No spaces on either side of the pipe

If there are more than one statement in quotation marks, separate them with semicolons


This article is from the "Wang Nimei Adult Road" blog, so be sure to keep this source http://8335914.blog.51cto.com/8325914/1611121

Shell Learning Notes (i)

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.