home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / unix / shell / 3857 < prev    next >
Encoding:
Text File  |  1992-09-08  |  1.7 KB  |  46 lines

  1. Newsgroups: comp.unix.shell
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!caen!sdd.hp.com!ux1.cso.uiuc.edu!news.cso.uiuc.edu!uxa.cso.uiuc.edu!dslg0849
  3. From: d-lewart@uiuc.edu (Daniel S. Lewart)
  4. Subject: Re: Awk problem
  5. References: <1992Sep8.113517.17401@news.uit.no>
  6. Message-ID: <Bu9z4t.6HJ@news.cso.uiuc.edu>
  7. Originator: dslg0849@uxa.cso.uiuc.edu
  8. Sender: usenet@news.cso.uiuc.edu (Net Noise owner)
  9. Reply-To: d-lewart@uiuc.edu (Daniel S. Lewart)
  10. Organization: University of Illinois at Urbana
  11. Date: Tue, 8 Sep 1992 19:50:51 GMT
  12. Lines: 32
  13.  
  14. ronnya@stud.cs.uit.no (Ronny Haavard Arild) writes:
  15.  
  16. > When I write this line in my shell (zsh):
  17.  
  18. > awk '/ .    [0-9.*]+ +[0-9]+ +[0-9.]+  */ {printf "%10s|%5s|%4s|%s\n", \
  19. > substr($0,7,10), substr($0,20,5), substr($0,27,4), substr($0,33,120)}' \
  20. > <oldfile> | tr "[A-Z]" "[a-z]" > <newfile>
  21.  
  22. > from this line in <oldfile>:
  23. >       0000001231     212   8.1  African Queen, The
  24.  
  25. > I get this line in <newfile>:
  26. > 0000001231|  212| 8.1|aGSMGAQ qZIIQ, tII
  27.  
  28. > While what I want is this:
  29. > 0000001231|  212| 8.1|african queen, the
  30.  
  31. > Could someone please help me out, as I'm stuck. From the little I know about
  32. > awk this should work.
  33.  
  34. It works on my machine; I think your `awk' may be broken.  Why don't you
  35. try one of the following?
  36. -------------------------------------------------------------------------------
  37. gawk '{printf("%s|%5d|%4.1f|%s\n",$1,$2,$3,tolower(substr($0,33)))}' \
  38.     oldfile > newfile
  39. -------------------------------------------------------------------------------
  40. awk '{printf("%s|%5d|%4.1f|%s\n",$1,$2,$3,substr($0,33))}' \
  41.     oldfile | tr "[A-Z]" "[a-z]" > newfile
  42. -------------------------------------------------------------------------------
  43.  
  44. Daniel Lewart
  45. d-lewart@uiuc.edu
  46.