extract words having >16 characters

extract words having >16 characters

Post by qazm » Fri, 08 Mar 2002 23:03:30



From a text file, I want to extract only the words that contain more
than 16 characters.

How do you do this using vi editor or from the shell prompt?

 
 
 

extract words having >16 characters

Post by Joe Halpi » Fri, 08 Mar 2002 23:21:15



> From a text file, I want to extract only the words that contain more
> than 16 characters.

> How do you do this using vi editor or from the shell prompt?

One possibility:

awk '{for(i=1;i<=NF;i++) if(length($i) > 16) print $i}' file

Joe

 
 
 

extract words having >16 characters

Post by Tapani Tarvaine » Fri, 08 Mar 2002 23:44:16



> From a text file, I want to extract only the words that contain more
> than 16 characters.

> How do you do this using vi editor or from the shell prompt?

The main difficulty is defining "word"... but try something like this:

tr -c '[:alpha:]' '[\n*]' < file | awk 'length>16'

You may have to adjust the 'tr' command to match your notion of word.

--
Tapani Tarvainen

 
 
 

extract words having >16 characters

Post by Charles E. Campbe » Sat, 09 Mar 2002 01:09:53




>From a text file, I want to extract only the words that contain more
>than 16 characters.

>How do you do this using vi editor or from the shell prompt?

Using vi (not vim):

:1,$s/[ \t]/^M/g
:v/[a-zA-Z][a-zA-Z][a-zA-Z][a-zA-Z][a-zA-Z][a-zA-Z][a-zA-Z][a-zA-Z][a-zA-Z][a-zA-Z][a-zA-Z][a-zA-Z][a-zA-Z][a-zA-Z][a-zA-Z][a-zA-Z][a-zA-Z]/d

(17 repeats of [a-zA-Z])
( ^M use ctrl-v ctrl-m )

Regards,
C Campbell
--
        Charles E Campbell, Jr, PhD            _   __   __
        Goddard Space Flight Center           / /_/\_\_/ /

  PGP public key: http://www.erols.com/astronaut/pgp.html

 
 
 

extract words having >16 characters

Post by Pepp » Sat, 09 Mar 2002 01:43:31





> >From a text file, I want to extract only the words that contain more
> >than 16 characters.
> >How do you do this using vi editor or from the shell prompt?
> Using vi (not vim):
> :1,$s/[ \t]/^M/g

Does your vi understand "\t" or is it a typed tab character?

Quote:> :v/[a-zA-Z][a-zA-Z][a-zA-Z][a-zA-Z][a-zA-Z][a-zA-Z][a-zA-Z][a-zA-Z][a-zA-Z][a-zA-Z][a-zA-Z][a-zA-Z][a-zA-Z][a-zA-Z][a-zA-Z][a-zA-Z][a-zA-Z]/d
> (17 repeats of [a-zA-Z])

How about ":v/[a-zA-Z]\{17\}/d".

Btw, are there any vi's that don't understand this syntax (or "\{17,17\}")?

Peppe   [just curious]
--
                                      "Before you criticize someone, walk
Preben "Peppe" Guldberg  __/-\__       a mile in his shoes. That way, if

----------------------oOOo (_) oOOo--  - and barefoot."    --Sarah Jackson

 
 
 

extract words having >16 characters

Post by those who know me have no need of my nam » Sat, 09 Mar 2002 08:18:01



Quote:>How about ":v/[a-zA-Z]\{17\}/d".

>Btw, are there any vi's that don't understand this syntax (or "\{17,17\}")?

many.  e.g.,

nvi: Version 1.79 (10/23/96) The CSRG, University of California, Berkeley.
says: The v command doesn't permit an address of 0.

--
okay, have a sig then

 
 
 

extract words having >16 characters

Post by John W. Krah » Sat, 09 Mar 2002 13:57:10



> From a text file, I want to extract only the words that contain more
> than 16 characters.

> How do you do this using vi editor or from the shell prompt?

perl -lne'print for/\w{17,}/g' yourfile.txt

John
--
use Perl;
program
fulfillment

 
 
 

1. enlightenment 0.16.4->0.16.5 patch?

hi folks

i've just seen that enlightenment has had a minor patch release...
question i have is, does anyone know where (if it exists) a patch
file for this release and the last

i can only find the entire tar balls and just dont have the bandwidth to
grab 11megs of src.

thanks in advance
ray

Sent via Deja.com http://www.deja.com/
Before you buy.

2. mount from one AIX server to another fails

3. ### 8M --> 16 megs ---> computer not faster?

4. Top 10 posters comp.unix.shell

5. Another SB-16 problem << MOUNT POINT \cdrom DOES NOT EXIST >>

6. Need help sorting coordinates.

7. CL-GD 5428 >8bpp >16 M patch

8. Max filesystem size OSR5.05 ?

9. Does having 16 MB of RAM make a BIG difference.

10. Does having 16 MB of RAM make a BIG differe

11. Does having 16 MB of

12. About 16 Word BigCrypt@

13. 16 character hostname