Longest word in a file

I am trying to write a command on just one line, i.e seperated by ';' and '|' etc, that finds the number of characters in the longest word of a file, preferably using the 'tr' and 'wc' commands.

i no that wc shows the number of lines words and characters in a file but im not sure how to use it to find the longest word???

Any help much appreciated, thanks.

Use tr to read the file and translate all spaces into newlines. Pipe to wc and use the -L option that reports the longest line.

As this smells a bit like homework, I'm not going to provide the exact command -- if it's not homework, then say so and someone will provide more details I'm sure.

(and as a side note, since I see it done way too often, there is no need to use cat to do this!)

Am I missing something here, why do you want to use the 'tr' command?

Regards

Dave

yes its homework, i am an absolute unix beginner so no nothing.

if you were able to tell me how i would go about approaching this kind of question because i genuinely have no idea :s that would be awesome then ill try figure out a command from there.

tr and wc were just suggested commands to use

It's an easy way to make each individual word its own line. Then you just hunt for the longest line.

Do not post classroom or homework problems in the main forums. Homework and coursework questions can only be posted in this forum under special homework rules.

Please review the rules, which you agreed to when you registered, if you have not already done so.

More-than-likely, posting homework in the main forums has resulting in a forum infraction. If you did not post homework, please explain the company you work for and the nature of the problem you are working on.

If you did post homework in the main forums, please review the guidelines for posting homework and repost.

Thank You.

The UNIX and Linux Forums.