perl -ni.old -e "print $_ unless $_{$_}++" foo.txt