Firstly, quotes, quotes and more quotes. Variables without quotes in bash can cause unpredictable results.
You may need to explain further what you need as the cat, awk, sort, uniq and head output is not clear (I would add that awk can probably do all of those for you)
As for reading a file, use a while, read loop:
Code:
while read var
do
<your stuff here>
done<"$fname"
Here 'var' will store each line read from the file for you to work on.
If this is not what you require, please explain further?