Shell programming-annotations, strings and Arrays (iv)

Source: Internet
Author: User

Shell annotations
Use # as the comment symbol
There are no multiple lines of comments in the shell, only one line plus a # number

String manipulation
1. Stitching strings
    

2. Get the string length
String= "KHJF"
echo ${#string}

3. Extracting substrings
String= "Tynam is a good mans"
Echo ${string:1:4}


Array
Equivalent to multiple sets of variables of the same type, without limiting the size of the array in the shell
Defining arrays
In the shell, the array is represented by parentheses, and the array elements are separated by a "space" symbol
General form: array= (value0 value1 value2 value3 value4)
To add an array of values individually: ARRAY[0]=VALUE0
Array[1]=value1

Get array
    

Gets the length of the array
    

Practice

   

Answer

  

Shell programming-annotations, strings and Arrays (iv)

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.