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 |
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 withprintf
(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
$COLUMNS
defines total width
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.
$LANG
, $LC_ALL
and $LC_CTYPE
affect the execution
$ 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 #WithRemoves characters starting at the 2nd character through the 3rd character122 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
start
bigger than the number of columns shows all the columns:
$ echo "abcdefgh" | colrm 20 abcdefghWith
start
of 1 outputs nothing:
$ echo "abcdefgh" | colrm 1 $