home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / unix / question / 15331 < prev    next >
Encoding:
Text File  |  1993-01-08  |  1.2 KB  |  31 lines

  1. Newsgroups: comp.unix.questions
  2. Path: sparky!uunet!europa.asd.contel.com!emory!swrinde!zaphod.mps.ohio-state.edu!saimiri.primate.wisc.edu!eng.ufl.edu!spp
  3. From: spp@crane.cis.ufl.edu (Stephen P. Potter)
  4. Subject: Re: counting spaces
  5. Message-ID: <1993Jan8.164058.2454@eng.ufl.edu>
  6. Sender: news@eng.ufl.edu (Usenet Diskhog System)
  7. Organization: Univ. of Florida CIS Dept.
  8. References: <1993Jan7.191409.25394@netnews.whoi.edu>
  9. Date: Fri, 8 Jan 93 16:40:58 GMT
  10. Lines: 19
  11.  
  12. In article <1993Jan7.191409.25394@netnews.whoi.edu> eklein@whsun1.wh.whoi.edu writes:
  13. >
  14. >How do you count the spaces in a text file using Unix commands? Sounds simple
  15. >dosen't it.
  16.  
  17.  
  18. This can be taken many ways.  I personally decided to take it literally.  You
  19. want to know how many times the space bar was pressed in the file.  IE, I do
  20. not count <tab> as being eight spaces or anything like that.
  21.  
  22. tr '\012' "#" <$infile | tr " " '\012' | wc -l
  23.  
  24.  
  25. Steve
  26. -- 
  27.     cccc    i   ssss   University of Florida  Computer and Information Sciences
  28.   c           s        Unix Consulting Staff   (904) 392-1183  E309A 
  29.  c        i   ssss     Email: spp@cis.ufl.edu, u4930any@elm.circa.ufl.edu
  30. c        i       s            PRISONER@ufcc.ufl.edu, Bitnet: PRISONER@ufcc       cccc   i    ssss
  31.