O'Reilly logo
  • Rusty Eddy thinks this is interesting:

#! /bin/sh
awk -F, '{ 
	print $4 ", " $0 
	}' $* | 
sort |
awk -F, '
$1 == LastState { 
      print "\t" $2
}
$1 != LastState { 
      LastState = $1
      print $1
      print "\t" $2
}'

From

Cover of sed & awk, 2nd Edition

Note

Make headers from a csv records.