Supposing you have a string value in a variable STRING
, how can you remove leading and trailing whitespaces with a single command (line)?
For instance, the string is (the _
stands for tab here; double-quotes just for illustration, not part of string value):
" two spaces, trimmed text string, space-tab-space _ "
The expected output is (double-quotes again not part of string):
"two spaces, trimmed text string, space-tab-space"
How to accomplish that?
In this context, I'm talking about spaces and (horizontal) tabulators when I say "whitespaces".