Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'd like to use Unix column 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"
share|improve this question

2 Answers 2

column -t -s '\t'

would separate columns on \ and t characters.

column -s \t is the same as column -s t.

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

column -ts $'\t'

Or enter a real tab character by typing Ctrl-V Tab at the shell prompt, or use "$(printf '\t')".

share|improve this answer

The -t is for selecting the number of columns you want. Leaving this blank does not change anything. Also, you want white space after the -s so try this out:

cat myfile | column -s \t

share|improve this answer
    
Thanks. This is close to what I am looking for. However, now all the lines are merged onto one line. How can I keep each line on its own line? –  turtle Nov 30 '12 at 10:09
    
By default, column fills rows before columns. You may be interested in pr –  lurker Nov 30 '12 at 10:35

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.