File:  [Plan 9 NeXT] / lucent / sys / src / 9 / port / f002544
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 18:01:03 2018 UTC (8 years, 1 month ago) by root
Branches: lucent, MAIN
CVS tags: plan9, HEAD
Plan 9 NeXT

#!/bin/rc

switch($#*){
case [012]
	echo usage: mkextract [-u] field n file... >[1=2]
	exit 1
}

switch($1){
case -u
	flag=$1; shift
case *
	flag=''
}

field=$1
n=$2
shift 2

fn select {
	awk '

		BEGIN			{ doprint=0 }
		/^$/			{ next }
		/^#/			{ next }
		doprint && /^[^	]/	{ doprint=0 }
		doprint			{ print $'^$n^' }
		$0 ~ "^'^$field^'"	{ doprint=1; next }
	' $*
}

switch($flag){
case -u
	select $* | sort -u
case *
	select $*
}

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.