It is currently Fri, 15 Oct 2021 20:52:01 GMT



 
Author Message
 sed: Can it find the longest word on a line?
Subject line says it.


 Tue, 01 Mar 1994 07:41:05 GMT   
 sed: Can it find the longest word on a line?
It might, but awk would be a whole lot easier.


 Tue, 01 Mar 1994 23:11:07 GMT   
 sed: Can it find the longest word on a line?
Here's a Perl (version 4 patchlevel 10) solution:

perl -alne 'grep(do{($l,$w)=(length,$_)if length>$l;},@F);\
        print $w;reset lw;' file

It will print, for each line of file, only the longest word.

Martin



 Tue, 01 Mar 1994 21:49:52 GMT   
 
   [ 3 post ] 

Similar Threads

1. a SED script to find length of the longest line in a file

2. sed: splitting word over several lines

3. : split lines in long 'sed'-pattern ?

4. Line to long for sed?

5. sed on LONG lines

6. finding files with words that may be on different lines

7. How to find if the last line ends with a specified word

8. How to find the last line that contains a word in file

9. How to find the first readable word in one line

10. How to find out all the input args of a long command line


 
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software