There are some things here that can stand some clarification and warnings ...
The vi and sed solutions above will remove ALL leading spaces on each line. If desired, they could be changed to delete just the first space in each line by dropping that asterisk, which in an RE means zero or more of the preceding character.
You can demo this in vi on a file that has some leading spaces in some of the lines. The following search:
/^ *
will find the beginning of EACH line because we are asking for begin-of-line followed by zero-or-more spaces. But if you do the same search without the asterisk (search pattern is carat-space), it will find only those lines that begin with a space (does not matter what if anything follows the space).
The while-read solution deletes only a single leading space from each line. The asterisk in this context is not the same as the vi and sed solutions. It actually stands for any and all characters, just like when you do:
ls xyz*
The following korn shell expressions are identical:
${line# *}
${line# }
The first evaluates to the value of $line after removing the SHORTEST qualifying pattern at the beginning of $line that begins with a space and followed by any and all characters (which, for lines beginning with one or more spaces, will end up being a single space).
The second expression likewise removes the shortest qualifying expression from $line, the expression being a single space.
The expression:
${line## *}
(with two pound signs) removes the LONGEST qualifying expression of space-asterisk which means a space followed by everything. In other words, that expression would totally nullify each line beginning with a space.
I see that the while-read is somewhat better performance (at least on HP-UX) than the sed, but the BIG problem with the while-read solution is that it does not preserve your spacing, such as if you had multiple spaces between fields. That can be easily corrected with double-quotes, and we don't need that assignment to line either:
echo "${line# *}"
But to get this solution to eliminate ALL the leading spaces is a bit trickier.