# The syntax is to remove leading whitespaces:${var##*( )}
1
2
3
4
5
6
7
8
9
10
# Just remove leading whiltespace#turn it onshopt -s extglob
output=" This is a test"output="${output##*( )}"echo"=${output}="# turn it offshopt -u extglob
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# To trim leading and trailing whitespace using bash#turn it onshopt -s extglob
output=" This is a test "### Trim leading whitespaces ###output="${output##*( )}"### trim trailing whitespaces ##output="${output%%*( )}
echo "=${output}="
# turn it off
shopt -u extglob