≡ Menu

bash extglob

Bash Shell: Trim Leading White Space From Input Variables

My script depends upon $1 to take certain actions:

file=”$1″
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…]

Sysadmin because even developers need heroes!!!