Linux shell programming ---- advanced usage of variables 1 Internal Variable 1 internal variables refer to variables that can affect the behavior of bash shell scripts. They are effective for shell and its subshells. 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