Tips

How to get the source directory of a Bash script from within the script itself?

※ source

#!/bin/bash

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

How to obtain the first letter in a Bash variable?

※ source

word='tiger'
echo "${word::1}"
echo "${word}" | cut -c 1
echo "${word:0:1}"

Printing a sequence of letters or numbers in shell

※ source

Print a sequence of number

$ seq 1 10
1 2 3 4 5 6 7 8 9 10

$ seq 0 2 10
0 2 4 6 8 10

$ echo {1..10}
1 2 3 4 5 6 7 8 9 10

Print a sequence of letters

$ echo {a..g}
a b c d e f g