≡ Menu

read command trim while space

Bash Shell: Trim Leading White Space From Input Variables

My script depends upon $1 to take certain actions:

echo "|${file}|"

However, sometime there will leading while space which will result into:

|     output.txt|

How do I trim leading white space from one of my input variables?
[click to continue…]