Linuxshell programming-Advanced usage of variables

Source: Internet
Author: User
Linuxshell programming ---- advanced usage of variables 1 internal variable 1 internal variables refer to variables that can affect the behavior of bashshell scripts. they are effective for shell and its subshells. 2. next we will introduce several common internal variable names: Linux shell programming ---- advanced usage of variables 1 internal variable 1 internal variable 1 refers to the variables that can affect the behavior of bash shell scripts, they are valid for both the shell and its sub-shell. 2 below we will introduce several common internal variable name meanings BASH bash records the bash shell path, usually/bin/BASH, we can use echo $ BASH to view the host name HOSTNAME record the host name HOSTTYPE record the hardware architecture of the system MACHTYPE is also record the hardware architecture of the system OSTYPE record the type of the operating system 2 string processing 1 next we will introduce the expr command, it is mainly used to process string 2 to calculate the string length $ {# string} or expr length $ string 3 expr index command expr index $ string $ substring // The function is to match on string position where substring appears for the first time, if no value is returned for the 0 4 expr match command expr match $ string $ substring // The function matches the substring at the beginning of the string and returns the matched length, if the start character does not match, 0 is returned. the substring can be a string or a substring extracted from string by regular expression 5 # {string: position} // Extract substring from position to end # {string: position: length} // Extract length-long substring 6 from position to delete substring $ {string: subdtring} // delete the shortest substring that matches the substring at the beginning of string $ {string: # substring} // delete the nth child string that matches the substring at the beginning of the string, and replace the 7th child string $ {string/substring/resplacement} // only replace the child that matches the substring for the first time. string $ {string // substring/resplacement} // replace all child matching the substring
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.