[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: what is the use of -c parameter of column(1), can you demonstrate with an example?



On 11/02/2010 05:01 AM, Chris Jackson wrote:
> Zhang Weiwu wrote:
> 
>>  from man column(1)
>>
>>      -c      Output is formatted for a display columns wide.
>>
>> Try:
>>
>> almustafa@orphalese:~$ echo aaa bbb | column  -c 20
>>
>>
>> expected result (17 spaces):
>>
>> aaa                bbb
>>
>> actual result:
>>
>> almustafa@orphalese:~$ echo aaa bbb | column  -c 20
>> aaa bbb
>>
>> Confusing. Or do I misunderstand the purpose of column(1)?
>>
>> Thanks.
> 
> 
> -c is for the total number of columns. Having said that, I can't get it
> to actually do anything, so I could be wrong.

The question is, "What is a column?"

In the case of -c, I think it's one character.  As in a terminal window
of 80 columns and 24 lines.

For the column command, it looks like it's a "line" of input.

So, to use another poster's suggestion, but running in a terminal window
that has been widened to 155 columns x 25 lines:

  ls -l | sed 1d | column

I got one "column", looking just like the ls -l would have, minus the
first line.

I tried -c 40, no difference.  But a -c 250, I got two "columns", with
wrapping of the long lines.  Each column was a list of complete lines
from from the ls:

  -rw-r--r-- 1 ....... filename   drw-r--r-- 2 ...... dirname

And so on.

> 
> You could perhaps use awk:
> 
> http://unstableme.blogspot.com/2008/12/awk-formatting-fields-into-columns.html
> 
> (bit fugly) or, depending on exactly what you need, look at pr(1).
> 
> --
> Chris Jackson
> Shadowcat Systems Ltd.
> 
> 

-- 
Bob McGowan


Reply to: