The first issue is the control Z, in a standard setup, it suspends the job, leaving it in the background not running. You will notice this with exit, which will tell you you have stopped jobs. (other job control commands may also) What you wanted was Control D which when typed at a terminal sends an End of File. This is very different from dos and windows.
Secondly, when you see cat in a script 90% of the time it is not needed. There are three ways to do what you are trying to do without the use of cat that come to the top of my head:
tee
tee /tmp/sortme | sort | diff - <(sort -u /tmp/sortme)you can also replace the temporary file with a named link.using uniq -d
sort | uniq -dxclip which allows you to access the clipboard from the command line so you do not have to send a EOF. It can also be combined with the two previous options so that all four of these lines will do what you want.
xclip -o > /tmp/sortme ; diff <(sort /tmp/sortme) <(sort -u /tmp/sortme) diff <(xclip -o|sort) <(xclip -o|sort -u) xclip -o|tee /tmp/sortme | sort | diff - <(sort -u /tmp/sortme) xclip -o|sort | uniq -d
xclip -o > /tmp/sortme ; diff <(sort /tmp/sortme) <(sort -u /tmp/sortme) diff <(xclip -o|sort) <(xclip -o|sort -u) xclip -o|tee /tmp/sortme | sort | diff - <(sort -u /tmp/sortme) xclip -o|sort | uniq -d