giovedì 2 aprile 2015

Simple uniq alternative

uniq is a Unix utility which, when fed a text file, outputs the file with adjacent identical lines collapsed to one.

Here a simple alternative

alias uniq='while read line; do if [ "$line" != "$PREVIOUS" ]; then echo $line; PREVIOUS=$line; fi; done'