Plan 9 from Bell Labs’s /usr/web/sources/contrib/someone/root/rc/bin/column

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


#!/bin/rc
# column [-F sep] [n...]] - print n'th column(s); `n' may be `NF'
rfork e
switch ($1) {
case -F
	if (~ $2 '\t')
		sep='-F	'
	if not
		sep=-F^$"2
	shift 2
case -F?*
	if (~ $1 '-F\t')
		sep='-F	'
	if not
		sep=$1
	shift
}

switch ($#*) {
case 0
	* = 1
case *
	if (! ~ $1 NF [0-9] [0-9][0-9] [0-9][0-9][0-9]) {
		echo usage: $0 '[-F sep] [n...]' >[1=2]
		exit usage
	}
}
arglist=`{echo $* | sed -e 's/NF|[0-9]+/$&,/g' -e 's/,$//'}
exec awk $sep '{print '^$"arglist^'}'

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.