#!/bin/csh -f

# See mkmatrix.awksh for output format

setenv LANG C

if ($#argv != 2) then
	echo Usage: $0 phaseN.txt prefix
	echo '    (over)writes prefix-phaseN.txt'
	echo '    E.g.,' $0 'phase2.txt app'
	exit $#argv
	endif

set inf = $1
set pfx = $2
set outf = ${pfx}-${inf}

set pfxupper = `echo $pfx | awk '{print toupper($1);}' `
cat $inf | \
  egrep '^'$pfxupper | \
  sed -e 's/^[^|]*| *//' | \
  sort | \
  cat > $outf

exit 0

