fun, although I did cheat a bit on the corrupted text and pulled the expected output from README instead of the input file :)
awk '{printf "%2d %s\n", NR, $0}' < faces.txt | sort -k 2 -u | sort -n | sed 's/^...//'
Ironically, it also involved awk! But I used it to prepend line numbers, which uniq and sort can ignore, then re-sort it according to line numbers. Very much not an ideal solution!awk '!h[$0] {h[$0]=1; print}' faces.txt
That is clever! Awk golf hole-in-one ;-)
Also, I learned today that cat takes a -n option to prepend line numbers to the output! My solution ended up being
cat -n faces.txt | sort -k2 -k1n | uniq -f1 | sort -nk1,1 | cut -f2-< war_and_peace.txt tr -s '!' | sed 's/!\([a-z]\)/\1/g' | sed 's/!\( [a-z]\)/\1/g' | sed 's/!\.!/./g' | sed 's/ !/ /g'
However, I don't think I learnt much from that. :-)
awk '{l++;gsub("!","");t[1]=4;t[4]=2;t[9]=3;o=$1;for(i=2;i<=NF;i++){o=o " " $i (i==t[l]?"!":"")};print o}' war_and_peace.txt seq -s ' ' 1 100