The man page for unexpand
states:
By default, only leading blanks and tabs are reconverted to maximal strings of tabs.
However, it seems to definitely be converting internal blanks as well:
echo " HELLO THERE" | unexpand -t 2 | tr '\t' '_'
yields
_HELLO_ THERE
instead of the expected
_HELLO THERE
This is the output I'd expect if I included the -a
option, but the output is the same with or without that option.
From the POSIX spec, emphasis added:
When
-t
is specified, the presence or absence of the-a
option shall be ignored; conversion shall not be limited to the processing of leading<blank>
characters.
The GNU coreutils version of expand
(but not the BSD one used by Apple) has a --first-only
option which counteracts this behavior.