#!/bin/bash #V0.1 OldHostField='' OldKeyInfo='' CurrentHostList='' #Do not use sort -k2 -u ; mac os/x sort doesn't work correctly in this case ( sed -e 's/[[:space:]][[:space:]]*/ /g' | sort --key=2,3 | uniq ; echo ) \ | while read HostField KeyInfo ; do if [ -n "$OldKeyInfo" -a "$OldKeyInfo" != "$KeyInfo" ]; then #Close out old line Pad='' if [ ${#CurrentHostList} -lt 80 ]; then for X in `seq ${#CurrentHostList} 80` ; do Pad="$Pad " done fi echo "$CurrentHostList$Pad $OldKeyInfo" CurrentHostList='' fi if [ "$CurrentHostList" != '' ]; then CurrentHostList="$CurrentHostList," fi CurrentHostList="$CurrentHostList$HostField" OldHostField="$HostField" OldKeyInfo="$KeyInfo" done