For POSIX, $'...'
, as known as ANSI-C escaping, isn't defined.
Instead, you can use the POSIX $(printf '\t')
:
column -t -s "$(printf '\t')"
$(printf '\011')
could be used, as 011
(octal representation of decimal 9) is the ANSI code for a horizontal tab character:
column -t -s "$(printf '\011')"
However this is discouraged as it was commented under this and his answer by Stéphane Chazelas. This is because it may not be consistent across shell versions as POSIX doesn't specify what the encoding of TAB is. There are still POSIX systems whose C locale encoding is EBCDIC based where TAB is 5, not 9 like in ASCII. Wherever possible, it's better to refer to characters by name (\t
here) to avoid this kind of issue. Note that $'...'
is planned for inclusion in the next major version of the POSIX specification as of Sep 10, 2018.
column -t -s $'\t'
as bash seemed to think'\t'
mean both\
andt
, but$'\t'
means a literal tab. Bash stinks – ThorSummoner Jun 21 '16 at 22:11$'\t'
makes tab the delimiter. But I'm pretty sure I doawk -F "\t"
to use a tab as a delimiter for awk. Why does that work and not here for column? – Mike Dec 07 '18 at 01:38$'\t'
syntax... great tip! – NerdyDeeds Dec 26 '22 at 01:42