#!/bin/ksh -p # Path tidying script IFS=" : " set -A p $PATH c=0 set -A newp $( while (( $((c+1)) < ${#p[*]} )) ; do print -n "${p[$c]} " c=$(( c + 1 )) if (( $((c+1)) == ${#p[*]} )) ; then print "" ; fi done | sort | uniq ) IFS=" " # There's a space after the first IFS quote above! NPATH="" c=0 while (( $((c+1)) < ${#newp[*]} )) ; do NPATH="$NPATH${newp[$c]}" c=$(( c + 1 )) if (( $((c+1)) < ${#newp[*]} )) ; then NPATH="$NPATH:" ; fi done echo $NPATH