Lum – How to use column to delimit on tabs and not spaces

columnscommand linequotingtext processing

I'd like to use the Unix column command to format some text. I have fields delimited by tabs, but within each field there are also spaces. column delimits on white space (tabs and spaces). How can I make column only use tabs as the delimiter?

I was trying to specify tab as the delimiter using:

cat myfile | column -t -s"\t"

Best Answer

column -t -s '\t'

would separate columns on \ and t characters.

column -s \t is the same as column -s t, as the backslash is interpreted as a quoting operator by the shell.

Here you want to pass a real TAB character to column. With ksh93, zsh, bash, mksh, busybox sh or FreeBSD sh:

column -ts $'\t'

Or enter a real tab character by typing Ctrl-V Tab at the shell prompt (within quotes or preceded by a backslash as the tab character is a token separator in the shell syntax just like space), or use "$(printf '\t')" (those double quotes needed to disable the split+glob operator as the tab character also happens to be in the default value of $IFS).