Hey my friend was asking me if i knew a way to cout how many different words in a file. I told him no not off hand, but i was thinking about it, and i started to wonder also. I imagine this is probably pretty simple im just missing something, I keep confusing my self with how you would compair and filter out the same words twice or more. If any one knows of a way to do this id like to know.....
I know about the sort command with -u option and that it works
What i meant to say that the command which you have given is not the total solution for the question posted above. But that is again what i think, you may be right as well.
This is what I got from your command
but as per my understanding the output should have been 10 and not 12
ok i was working with the first idea. here is what i have so far. but for some reason this is not working, the command works but i think there is a problem with the input.
#!/bin/csh
echo "Please enter a filename: "
set filename = $<
set dif = `tr -d '.:"$(),-' < $filename | tr '[A-Z]' '[a-z]' | tr ' ' '\n' | sort | uniq | wc -l`
set num = `wc -l`
echo "Thank you, your file has $num words and $dif different words."
echo " "