* Proposal for new column(1) flag
@ 2022-10-13 19:26 Thomas Voss
2022-10-13 20:43 ` Bernhard Voelker
2022-10-17 8:42 ` Karel Zak
0 siblings, 2 replies; 5+ messages in thread
From: Thomas Voss @ 2022-10-13 19:26 UTC (permalink / raw)
To: util-linux
Hello there,
I'm not sure if this is exactly the right place to ask, so forgive me if
it isn't but I was thinking of a potential new flag for the column(1)
utility and would like to get some feedback on whether or not it would
even be accepted before I try to submit a patch.
The basic issue I am aiming to fix is this: When you have a bunch of
lines and you want to display them in a more "human friendly" manner, you
may decide to display them using columns. This is what ls does as the
default behavior when listing files and we can in theory do this by
piping the output of whatever command we run into column. The issue I
found however is that the way column operates is by splitting each row
into multiple columns where every column has the same width (a width
which can hold the longest input line). ls on the other hand tries to
make each column as thin as possible, with a gap of two spaces between
each column. This means that in many cases ls can fit the same data into
more columns than center can.
Now when listing files this is not a problem, you can always use ls
instead of center. But I recently found myself wanting to do this with a
list of movies that I had stored in a file, and so being able to just the
following would be much more convenient, but the gaps between the columns
is just too large:
$ column movie-list
So my proposal is to add a new flag, perhaps -g (g for gap) which allows
you to specify how wide you want the gaps between the columns to be in
spaces, and then to columnate that way. That change would make these two
lines identical:
$ ls *
$ ls * | column -g 2
- Thomas
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Proposal for new column(1) flag
2022-10-13 19:26 Proposal for new column(1) flag Thomas Voss
@ 2022-10-13 20:43 ` Bernhard Voelker
[not found] ` <CNO4L8IMOGYS.1DZ36WVMXZ8K4@mango-os>
2022-10-17 8:42 ` Karel Zak
1 sibling, 1 reply; 5+ messages in thread
From: Bernhard Voelker @ 2022-10-13 20:43 UTC (permalink / raw)
To: Thomas Voss, util-linux
[-- Attachment #1: Type: text/plain, Size: 1951 bytes --]
On 10/13/22 21:26, Thomas Voss wrote:
> Hello there,
>
> I'm not sure if this is exactly the right place to ask, so forgive me if
> it isn't but I was thinking of a potential new flag for the column(1)
> utility and would like to get some feedback on whether or not it would
> even be accepted before I try to submit a patch.
>
> The basic issue I am aiming to fix is this: When you have a bunch of
> lines and you want to display them in a more "human friendly" manner, you
> may decide to display them using columns. This is what ls does as the
> default behavior when listing files and we can in theory do this by
> piping the output of whatever command we run into column. The issue I
> found however is that the way column operates is by splitting each row
> into multiple columns where every column has the same width (a width
> which can hold the longest input line). ls on the other hand tries to
> make each column as thin as possible, with a gap of two spaces between
> each column. This means that in many cases ls can fit the same data into
> more columns than center can.
>
> Now when listing files this is not a problem, you can always use ls
> instead of center. But I recently found myself wanting to do this with a
> list of movies that I had stored in a file, and so being able to just the
> following would be much more convenient, but the gaps between the columns
> is just too large:
>
> $ column movie-list
>
> So my proposal is to add a new flag, perhaps -g (g for gap) which allows
> you to specify how wide you want the gaps between the columns to be in
> spaces, and then to columnate that way. That change would make these two
> lines identical:
>
> $ ls *
> $ ls * | column -g 2
>
> - Thomas
Hmm, you missed to give actual examples. Is it like the output of this?
$ ls * | column -xc $COLUMNS | column -t
(Example output in attached file to avoid line wrapping in the email.)
Have a nice day,
Berny
[-- Attachment #2: out --]
[-- Type: text/plain, Size: 2644 bytes --]
A$ AA$ AABCDEFHIJKLMNOPa1 AABCDEFHIJKLMNOPa2
AABCDEFHIJKLMNOPb1 AABCDEFHIJKLMNOPb2 AABCDEFHIJKLMNOPqwertyuiopasdfghjklzxcvbnm AABCDEFHIJKLMNOPz1234
AABCDEFa1 AABCDEFa2 AABCDEFb1 AABCDEFb2
AABCDEFqwertyuiopasdfghjklzxcvbnm AABCDEFz1234 ABCDEFA$ ABCDEFABCDEFHIJKLMNOPa1
ABCDEFABCDEFHIJKLMNOPa2 ABCDEFABCDEFHIJKLMNOPb1 ABCDEFABCDEFHIJKLMNOPb2 ABCDEFABCDEFHIJKLMNOPqwertyuiopasdfghjklzxcvbnm
ABCDEFABCDEFHIJKLMNOPz1234 ABCDEFABCDEFa1 ABCDEFABCDEFa2 ABCDEFABCDEFb1
ABCDEFABCDEFb2 ABCDEFABCDEFqwertyuiopasdfghjklzxcvbnm ABCDEFABCDEFz1234 ABCDEFHIJKLMNOPA$
ABCDEFHIJKLMNOPABCDEFHIJKLMNOPa1 ABCDEFHIJKLMNOPABCDEFHIJKLMNOPa2 ABCDEFHIJKLMNOPABCDEFHIJKLMNOPb1 ABCDEFHIJKLMNOPABCDEFHIJKLMNOPb2
ABCDEFHIJKLMNOPABCDEFHIJKLMNOPqwertyuiopasdfghjklzxcvbnm ABCDEFHIJKLMNOPABCDEFHIJKLMNOPz1234 ABCDEFHIJKLMNOPABCDEFa1 ABCDEFHIJKLMNOPABCDEFa2
ABCDEFHIJKLMNOPABCDEFb1 ABCDEFHIJKLMNOPABCDEFb2 ABCDEFHIJKLMNOPABCDEFqwertyuiopasdfghjklzxcvbnm ABCDEFHIJKLMNOPABCDEFz1234
ABCDEFHIJKLMNOPa1 ABCDEFHIJKLMNOPa2 ABCDEFHIJKLMNOPb1 ABCDEFHIJKLMNOPb2
ABCDEFHIJKLMNOPqwertyuiopasdfghjklzxcvbnm ABCDEFHIJKLMNOPz1234 ABCDEFa1 ABCDEFa2
ABCDEFb1 ABCDEFb2 ABCDEFqwertyuiopasdfghjklzxcvbnm ABCDEFz1234
Aa1 Aa2 Ab1 Ab2
Aqwertyuiopasdfghjklzxcvbnm Az1234 a1 a2
b1 b2 qwertyuiopasdfghjklzxcvbnm z1234
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: Proposal for new column(1) flag
2022-10-13 19:26 Proposal for new column(1) flag Thomas Voss
2022-10-13 20:43 ` Bernhard Voelker
@ 2022-10-17 8:42 ` Karel Zak
2022-10-17 10:10 ` Thomas Voss
1 sibling, 1 reply; 5+ messages in thread
From: Karel Zak @ 2022-10-17 8:42 UTC (permalink / raw)
To: Thomas Voss; +Cc: util-linux
On Thu, Oct 13, 2022 at 09:26:11PM +0200, Thomas Voss wrote:
> Hello there,
>
> I'm not sure if this is exactly the right place to ask, so forgive me if
> it isn't but I was thinking of a potential new flag for the column(1)
> utility and would like to get some feedback on whether or not it would
> even be accepted before I try to submit a patch.
>
> The basic issue I am aiming to fix is this: When you have a bunch of
> lines and you want to display them in a more "human friendly" manner, you
> may decide to display them using columns. This is what ls does as the
> default behavior when listing files and we can in theory do this by
> piping the output of whatever command we run into column. The issue I
> found however is that the way column operates is by splitting each row
> into multiple columns where every column has the same width (a width
> which can hold the longest input line). ls on the other hand tries to
> make each column as thin as possible, with a gap of two spaces between
> each column. This means that in many cases ls can fit the same data into
> more columns than center can.
>
> Now when listing files this is not a problem, you can always use ls
> instead of center. But I recently found myself wanting to do this with a
> list of movies that I had stored in a file, and so being able to just the
> following would be much more convenient, but the gaps between the columns
> is just too large:
>
> $ column movie-list
>
> So my proposal is to add a new flag, perhaps -g (g for gap) which allows
> you to specify how wide you want the gaps between the columns to be in
> spaces, and then to columnate that way. That change would make these two
> lines identical:
>
> $ ls *
> $ ls * | column -g 2
I guess you want "table" mode for the column (see --table-* options).
It provides almost all features from libsmartcols. The next important
thing for your use-case is --output-separator, for example
$ echo "AAA BBB CCC" | ./column -t --output-separator "..."
AAA...BBB...CCC
of course you can use " " to define space as separator, etc.
Karel
--
Karel Zak <kzak@redhat.com>
http://karelzak.blogspot.com
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: Proposal for new column(1) flag
2022-10-17 8:42 ` Karel Zak
@ 2022-10-17 10:10 ` Thomas Voss
0 siblings, 0 replies; 5+ messages in thread
From: Thomas Voss @ 2022-10-17 10:10 UTC (permalink / raw)
To: Karel Zak; +Cc: util-linux
On Mon Oct 17, 2022 at 10:42 AM CEST, Karel Zak wrote:
> I guess you want "table" mode for the column (see --table-* options).
> It provides almost all features from libsmartcols. The next important
> thing for your use-case is --output-separator, for example
>
> $ echo "AAA BBB CCC" | ./column -t --output-separator "..."
> AAA...BBB...CCC
>
> of course you can use " " to define space as separator, etc.
That doesn't quite work as a solution the moment that any item I want to
display in a column contains spaces though.
- Thomas
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-10-17 18:08 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-13 19:26 Proposal for new column(1) flag Thomas Voss
2022-10-13 20:43 ` Bernhard Voelker
[not found] ` <CNO4L8IMOGYS.1DZ36WVMXZ8K4@mango-os>
2022-10-17 18:08 ` Bernhard Voelker
2022-10-17 8:42 ` Karel Zak
2022-10-17 10:10 ` Thomas Voss
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox