for i in *.txt do mv $i $i~ perl -ne 'print length, "\t", $_' $i~ | \ sort +0n | uniq | cut -f2- > $i done