tcsh doesn't have a mechanism for including non-printing characters in string literals, other than including them directly.
In bash, you can do this (changing echo
to printf
because its behavior is more consistent):
$ printf "selected version\tnew version\nbbb\tccc\n" | column -t -s $'\t'
selected version new version
bbb ccc
In tcsh, you can replace the $'\t'
with a literal tab character, entered by typing Ctrl-VTab -- but when you read the code it's indistinguishable from a sequence of spaces.
Here's one solution, using the printf
command to convert \t
to a tab character:
% printf "selected version\tnew version\nbbb\tccc\n" | column -t -s "`printf '\t'`"
selected version new version
bbb ccc
You can also store the tab character in a variable; you can use either double quotes or the :t
suffix to retain the literal value when you use it:
% set tab = "`printf '\t'`"
% printf "selected version\tnew version\nbbb\tccc\n" | column -t -s "$tab"
selected version new version
bbb ccc
% printf "selected version\tnew version\nbbb\tccc\n" | column -t -s $tab:q
selected version new version
bbb ccc