Showing posts with label bash. Show all posts
Showing posts with label bash. Show all posts
bash - Substitution of variables
This link explains variable substitution in the Bash Shell.
For convenience a copy of some info in that post:
For convenience a copy of some info in that post:
- ${VAR-default}
If VAR is set (to any value, even null, then return $VAR, otherwise return the default value provided. VAR is unchanged. If the - is preceded by a colon (':') then the default value will also be returned in case the value of VAR is null. - ${VAR=default}
The same as '-' except that the value of VAR will be changed too. The use of the colon is the same in this case. - ${#VAR}
This returns the number of characters in VAR. (Unicode ???) - ${VAR#pattern}
Returns VAR with the shortest instance of pattern removed from the front.
Pattern is not a regular expression but a glob. If ## is used instead of # the longest matching pattern is removed from the front. - ${VAR%pattern}
Identical to # except the front will be the end of value of VAR
Subscribe to:
Posts (Atom)