As POSIX defined, the output of
wc shall contain an entry for each input file of the form:
"%d %d %d %s\n", <newlines>, <words>, <bytes>, <file>
But the output file format pseudo
printf() string differs from the System V version of
POSIX didn't require leading spaces to be added, so it's free for implementation to do what it want. There are different implementations of
wc, at least with OSX and
wc from heirloom tools chest, it added leading spaces to output.
$ /usr/5bin/wc -l /tmp/file
GNU wc also add leading spaces when reading from standard in and without any options:
$ cat file | wc
5 5 65
To remove all leading spaces, in POSIX shell:
set -- $nl
Note that this approach assume that variable only contain leading or trailing spaces, no spaces in the middle, like a b.