column

columnate lists

A verb make into columns, not a noun the columnS)

column [-tx ] [-c width] [-s sep] [file]

Formats input to multiple columns by removing sep and inserting [TAB] 0x09 characters or spaces to align columns left justified
Beware of multi word headings or footings. Use sed to remove them.

Mac version does not support "--" options

-t
--table
Create a table of columns.
-s sep
--separator
Set of characters to seperate input columns for -t . Default whitespace (?)
Default: Rows are filled down before columns across.
1   4    7  
 2   5    8
 3   62   29
 51  842  214
-x
--fillrows
Fill rows before filling columns aXross before filling rows down.
 1   2   3   
 4    5   631
 7    98   
-c width width of display (in characters )
Does not RESTRICT output to width, but may increase the number of columns shown!
Default $COLUMNS .
Some terminal emulators change $COLUMNS when screen size is changed.
 > echo $COLUMNS     
100
 > column f
172.17.55.206   172.17.55.211   172.17.55.216   172.17.55.221   172.17.55.226   172.17.55.231
 172.17.55.207   172.17.55.212   172.17.55.217   172.17.55.222   172.17.55.227   172.17.55.232
 172.17.55.208   172.17.55.213   172.17.55.218   172.17.55.223   172.17.55.228   172.17.55.233
 172.17.55.209   172.17.55.214   172.17.55.219   172.17.55.224   172.17.55.229   172.17.55.234
 172.17.55.210   172.17.55.215   172.17.55.220   172.17.55.225   172.17.55.230
 > column -c128 f
172.17.55.206   172.17.55.210   172.17.55.214   172.17.55.218   172.17.55.222   172.17.55.226   172.17.55.230   172.17.55.234
 172.17.55.207   172.17.55.211   172.17.55.215   172.17.55.219   172.17.55.223   172.17.55.227   172.17.55.231
 172.17.55.208   172.17.55.212   172.17.55.216   172.17.55.220   172.17.55.224   172.17.55.228   172.17.55.232
 172.17.55.209   172.17.55.213   172.17.55.217   172.17.55.221   172.17.55.225   172.17.55.229   172.17.55.233
Non Mac options
-n disables merging adjacent delimiters into a single delimiter when using -t ¬
-o
--output-separator string
output column separator, default is two spaces ¬
-oosep osep is used as output seperator (in some versions!)
-N
--table-columns name1[name2,…
Assign names to the columns. by comma separated list of names, for the table header or to address column in option arguments.
-e
--table-header-repeat
header line for each page.
-d
--table-noheadings
no header Use column names on the command line, but supresses the header.
-R
--table-right columns
Right align text in the columns.
-T
--table-truncate columns
columns which can be truncated, otherwise very wide entries may be output on multiple lines.
-E
--table-noextreme columns
Ignore unusually wide columns (wide thanr average) cells when calculating column width.
Has impact on the width calculation and table formatting, but the output text is not affected.
Used for the last visible column by default.
-W
--table-wrap columns
columns which use multi-line cell may be used for long text
-H
--table-hide columns
Don't output columns. The placeholder - may be used to hide all unnamed columns (see --table-columns).
-O
--table-order columns
column order on output.
-L
--table-empty-lines
Insert an empty line to the table for each empty line on input . Default ignore empty lines.
-r
--tree column
column to use tree-like output. the circular dependencies and other anomalies in child and parent relation are silently ignored.
-i
--tree-id column
column with line ID to create child-parent relation.
-p
--tree-parent column
column with parent ID to create child-parent relation.
-V
--version
Display version information and exit.
-h
--help
Display help text and exit.
-J
--json
Use JSON output format --table-columns is required and --table-name is recommended.
-n
--table-name name
the table name used for JSON output. Default table.

Empty lines and items are ignored.

> cat file
AFPServer:AFPUserAliases:Aliases:AppleMetaRecord:Augments:Automount:AutomountMap:b:Beta:biglonghairyword:tiny

RFPServer:RFPUserAliases:Rliases::Rugments:Rutomount:RutomountMap:b:Beta:biglonghairyword:tiny

> column  -t file
AFPServer  AFPUserAliases  Aliases  AppleMetaRecord  Augments   Automount     AutomountMap  b     Beta              biglonghairyword  tiny
RFPServer  RFPUserAliases  Rliases  Rugments         Rutomount  RutomountMap  b             Beta  biglonghairyword  tiny

> column wordlist|sed "s/\t/~/"
wer~    sdfagasdfg  avfagh      abfadfg     adfg
qwe~    aasd        ad      adxcva

> column wordlist|expand
wer             sdfagasdfg      avfagh          abfadfg         adfg
qwe             aasd            ad              adxcva

ls -l total 4520 -rw-r--r-- 1 tonylam staff 743 Jun 30 16:48 0 -rw-r--r-- 1 tonylam staff 10378 Oct 30 2020 0finderr -rw-r--r-- 1 tonylam staff 58 Mar 25 18:04 174.127.119.33 -rw-r--r--@ 1 tonylam staff 123883 Aug 7 2020 200704failure.ods drwx--x--x@ 90 tonylam staff 2880 Jun 30 12:44 Documents/ -rwx------@ 1 tonylam staff 22366 May 11 2007 DontUEverCHk.wav* drwx--x--x@ 398 tonylam staff 12736 Jun 29 14:06 Downloads/ drwx--x--x+ 71 tonylam staff 2272 Jun 28 12:01 Library/ lrwxr-xr-x 1 tonylam staff 8 Sep 16 2016 X11@ -> /opt/X11 lrwxr-xr-x 1 tonylam staff 8 Sep 16 2016 X11R6@ -> /opt/X11 Add heading with printf (printf "PERM LINKS OWNER GROUP SIZE MONTH DAY HH:MM/YEAR NAME\n" ; ls -l )|column -t PERM LINKS OWNER GROUP SIZE MONTH DAY HH:MM/YEAR NAME total 4520 -rw-r--r-- 1 tonylam staff 743 Jun 30 16:48 0 -rw-r--r-- 1 tonylam staff 10378 Oct 30 2020 0finderr -rw-r--r-- 1 tonylam staff 58 Mar 25 18:04 174.127.119.33 -rw-r--r--@ 1 tonylam staff 123883 Aug 7 2020 200704failure.ods drwx--x--x@ 90 tonylam staff 2880 Jun 30 12:44 Documents/ -rwx------@ 1 tonylam staff 22366 May 11 2007 DontUEverCHk.wav* drwx--x--x@ 398 tonylam staff 12736 Jun 29 14:06 Downloads/ drwx--x--x+ 71 tonylam staff 2272 Jun 28 12:01 Library/ lrwxr-xr-x 1 tonylam staff 8 Sep 16 2016 X11@ -> /opt/X11 lrwxr-xr-x 1 tonylam staff 8 Sep 16 2016 X11R6@-> /opt/X11

Environment

$COLUMNS defines total width


colrm

remove columns(characters) from lines

colrm [start [stop]]

Removes selected columns (i.e. characters !) from the lines of a file.
N.B. Not compatible with column or cut -f (fields)

Input from stdin, output to stdout.

Without start, output is unchanged.
With only start , characters before start will be written.
When both start and stop , characters before start or beyond stop will be written.
Numbering starts with 1.

Tabs increment the column count to the next multiple of 8.
Backspace decrement the column count by 1.

ENVIRONMENT

$LANG, $LC_ALL and $LC_CTYPE affect the execution

EXAMPLES

Show columns before 3 and beyond 5:
 $ echo -e "abcdefgh\nmyself" | colrm 3 5
           #12345678  1234567
           abfgh
           myf

With file col_test:

1        22  333   4444
2
3  1  2   3  4
4 1 2   3        4

> column -t coltest 
1  22  333  4444
2
3  1   2    3     4
4  1   2    3     4
1234567890123456789
> column -t col_test | colrm 2 3   # Removes characters starting at the  2nd character through the  3rd character
122  333  4444
2
31   2    3     4
41   2    3     4

> column -t col_test | colrm 2 2   # Removed only 2nd character.
1 22  333  4444                   # i.e. preserves character 1 and 3-
2
3 1   2    3     4
4 1   2    3     4

> column -t col_test | colrm 2     # Removes all  characters after the  2nd character.
1                                  # Preserves only characters before 2nd character.
2
3
4
With start bigger than the number of columns shows all the columns:
 $ echo "abcdefgh" | colrm 20
           abcdefgh
With start of 1 outputs nothing:
 $ echo "abcdefgh" | colrm 1 $

See also

expand,cut, ls , paste, sort,
stty [-]oxtabs output expands (-not expand) tabs to spaces