home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / unix / question / 10523 < prev    next >
Encoding:
Internet Message Format  |  1992-08-30  |  1.1 KB

  1. Path: sparky!uunet!auspex-gw!guy
  2. From: guy@Auspex.COM (Guy Harris)
  3. Newsgroups: comp.unix.questions
  4. Subject: Re: A question on ls
  5. Message-ID: <14370@auspex-gw.auspex.com>
  6. Date: 30 Aug 92 01:13:02 GMT
  7. References: <6786@tekig7.PEN.TEK.COM> <1992Aug29.233534.27967@umbc3.umbc.edu> <1992Aug29.235425.26762@mcc.com>
  8. Sender: news@auspex-gw.auspex.com
  9. Distribution: na
  10. Organization: Auspex Systems, Santa Clara
  11. Lines: 23
  12. Nntp-Posting-Host: auspex.auspex.com
  13.  
  14. >Not true, this should work in ALL shells:
  15. >
  16. >ls | grep -v '.Z'
  17.  
  18. Nope:
  19.  
  20.     bootme$ ls
  21.     alakaZam
  22.     bootme$ ls | grep -v '.Z'
  23.  
  24. Jim Davis's version is better; he suggested
  25.  
  26.     ls | grep -v '\.Z$'
  27.  
  28. The '\' in front of the '.' tells "grep" (or "egrep") that the "." isn't
  29. a single-character "wildcard" that'll match any character, but is
  30. supposed to match only the character '.'.  The '$' at the end tells
  31. "grep" (or "egrep") that it's supposed to match stuff that has '.Z' at
  32. the end, not stuff that has '.Z' in the middle.
  33.  
  34. That keeps it from matching "alakaZam", for example, which *does* match
  35. '.Z'; the '.' matches the 'a' before the 'Z', and it doesn't care if the
  36. 'Z' is at the end.
  37.