Shell script Programming {3} per day

Source: Internet
Author: User
Tags array length

Use of arrays

$array _var= (1 2 3)--use parentheses to define an array with a column value

$echo ${array_var[0]}--The first element of an array

$array _var[0]= "Zero"--defines an array using the form of an index and a value

$echo ${array_var[@]}--Print all array objects

$echo ${#array_var [*]}--Print array length

¥echo ${!array_var[*]}--iterating over the index value of an array

Use of associative arrays

Bash-version--Review the version information for Bash before introducing an associative array after bash4.0. You can use any text as the index value for bash.

Declare-a Array_var--defining associative arrays

$array _var= ([apple]=9.9 [banana]=5.5)--Array Association values

$array _var[orange]=3.2-- define an array using the form of an index and a value

$echo ${!array_var[*]}--iterating over the index value of an array

Using aliases

$alias xx= "Ls-al"--alias XX, represented in the current process Ls-al

$unalias xx--cancels the alias.

$ Echo ' Alias xx= ' Ls-al ' >> ~/.BASHRC--file. BASHRC, each process is read and will be permanently active. Remove the alias when you don't need it.

$alias rm= "CP [email protected] ~/backup;rm [email protected]"--Define an alias RM and keep a copy of the delete operation.

Shell script Programming {3} per day

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.