How to remove extra spaces in variable HEAD?
HEAD
HEAD=\" how to remove extra spaces \"
Result:>
I would make use of tr to remove the extra spaces, and xargs to trim the back and front.
TEXT=" This is some text " echo $(echo $TEXT | tr -s " " | xargs) # [...]$ This is some text