home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / unix / question / 15125 < prev    next >
Encoding:
Text File  |  1993-01-03  |  1.0 KB  |  28 lines

  1. Newsgroups: comp.unix.questions
  2. Path: sparky!uunet!psinntp!jpradley!jpr
  3. From: jpr@jpradley.jpr.com (Jean-Pierre Radley)
  4. Subject: Re: searching a file
  5. Date: Sun, 03 Jan 1993 07:07:21 GMT
  6. Message-ID: <1993Jan03.070721.14178@jpradley.jpr.com>
  7. References: <1993Jan3.021839.10462@mnemosyne.cs.du.edu>
  8. Organization: Unix in NYC
  9. Lines: 17
  10.  
  11. In article <1993Jan3.021839.10462@mnemosyne.cs.du.edu> sscrivan@nyx.cs.du.edu (steve scrivano) writes:
  12. >I want to search my /usr/dict/words and pull out lines by the occurrence
  13. >of certain letters in the words for example:  all lines that contain
  14. >no more than "2 l's" or no more than 3 "r's" or no more than one "n", etc.
  15. >How would I accomplish this considering letters can fall in different
  16. >places within a word?  A bin shell approach would be preferred.
  17. >
  18.  
  19. Here's a command to print all words in /usr/dict/words having 1, 2 or 3 "l"s:
  20.  
  21. </usr/dict/words tr '[A-Z]' '[a-z]' |
  22. sed -n '
  23. /^\([^l]*l[^l]*\)\1\{0,2\}$/p
  24. '
  25.  
  26. -- 
  27. Jean-Pierre Radley   Unix in NYC   jpr@jpr.com   jpradley!jpr   CIS: 72160.1341
  28.