scripts

Did you know Bash is this powerful ?

A couple of interesting bash stuff I found on the www:
(It's Public Domain)

1. Shell variables can be specified like $var or this ${var}.
$ var='a.ads,fssd2342%asd234#@.,&%,sdfgsdfgas4352'
echo ${var}
a.ads,fssd2342%asd234#@.,&%,sdfgsdfgas4352
2. ${#var} is the length of the variable.
$ echo ${#var}
42
3. ${var:pos} substrings the variable starting at pos.
$ echo ${var:10}
2342%asd234#@.,&%,sdfgsdfgas4352
4. ${var:pos:len} substrings the variable starting at pos with a max length of len.
$ echo ${var:10:5}
2342%
5. ${var#pattern} strips pattern from the front or left hand side of the variable. This form is not greedy meaning it stops as soon as the pattern is matched. ${var##pattern} is the greedy form.