#!/bin/rc flagfmt='n' args='file' if(! ifs=() eval `{aux/getflags $*} || ~ $#* 0) { aux/usage exit usage } argv0=$0 file=$1 tmp1=/tmp/tag.$pid.1 tmp2=/tmp/tag.$pid.2 fn cleanup { rm $tmp1 $tmp2 >[2]/dev/null } fn fatal { echo $argv0: $* >[1=2] cleanup exit $* } tag/read $file >$tmp1 || fatal read cat /fd/0 $tmp1 | tag/sort >$tmp2 || fatal sort if(! ~ $flagn '') cat $tmp2 if not tag/write $file <$tmp2 cleanup