$ cat com.txt | sed 's/^\(\S*\.com\)\.\s.*/\1/' | sort | uniq
A bit easier than a ruby script $ cat com.txt | sed 's/^\(\S*\.com\)\.\s.*/\1/' | sort | uniq
A bit easier than a ruby script cat com.txt | cut -d' ' -f1 | sort | uniq
Would work as well since there's no whitespace in the first column