Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ${parameter:-defaultValue}
- ${parameter:=defaultValue}
- ${parameter:?”ErrorMsg”}
- ${#var} - length of string
- ${var%pattern}
- ${var#Pattern} - Remove from $var the shortest part of $Pattern that matches the front end
- ${var##Pattern} - Remove from $var the longest part of $Pattern that matches the front end
- ${var%Pattern} - Remove from $var the shortest part of $Pattern that matches the back end
- ${var%%Pattern} - Remove from $var the longest part of $Pattern that matches the back end
- ${var:pos} - Variable var expanded, starting from offset pos.
- ${var:pos:len} - Expansion to a max of len characters of variable var, from offset pos
- ${var/Pattern/Replacement} - First match of Pattern, within var replaced with Replacement.
- ${var//Pattern/Replacement} - Global replacement. All matches of Pattern, within var replaced.
- ${var/#Pattern/Replacement} - If prefix of var matches Pattern, then substitute Replacement for Pattern.
- ${var/%Pattern/Replacement} - If suffix of var matches Pattern, then substitute Replacement for Pattern.
- ${!varprefix*}, ${!varprefix@} - Matches names of all previously declared variables beginning with varprefix.
- numeric validation = [[ $var == ${var//[^0-9]/} ]] || echo “Not numeric”
Add Comment
Please, Sign In to add comment