3
0

var_bash1a.tests 395 B

1234567891011
  1. parameter=abcdef
  2. offset=2
  3. noffset=-2
  4. echo "parameter '${parameter}'"
  5. echo "varoffset2 '${parameter:${offset}}'"
  6. echo "varoffset-2 '${parameter:${noffset}}'"
  7. echo "literal '2' '${parameter:2}'"
  8. # This is not interpreted as ${VAR:POS{:LEN}},
  9. # but as ${VAR:=WORD} - if VAR is unset or null, substitute WORD
  10. echo "literal '-2' '${parameter:-2}'"
  11. echo "literal ' -2' '${parameter: -2}'"