home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.shell
- 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
- From: d-lewart@uiuc.edu (Daniel S. Lewart)
- Subject: Re: Awk problem
- References: <1992Sep8.113517.17401@news.uit.no>
- Message-ID: <Bu9z4t.6HJ@news.cso.uiuc.edu>
- Originator: dslg0849@uxa.cso.uiuc.edu
- Sender: usenet@news.cso.uiuc.edu (Net Noise owner)
- Reply-To: d-lewart@uiuc.edu (Daniel S. Lewart)
- Organization: University of Illinois at Urbana
- Date: Tue, 8 Sep 1992 19:50:51 GMT
- Lines: 32
-
- ronnya@stud.cs.uit.no (Ronny Haavard Arild) writes:
-
- > When I write this line in my shell (zsh):
-
- > awk '/ . [0-9.*]+ +[0-9]+ +[0-9.]+ */ {printf "%10s|%5s|%4s|%s\n", \
- > substr($0,7,10), substr($0,20,5), substr($0,27,4), substr($0,33,120)}' \
- > <oldfile> | tr "[A-Z]" "[a-z]" > <newfile>
-
- > from this line in <oldfile>:
- > 0000001231 212 8.1 African Queen, The
-
- > I get this line in <newfile>:
- > 0000001231| 212| 8.1|aGSMGAQ qZIIQ, tII
-
- > While what I want is this:
- > 0000001231| 212| 8.1|african queen, the
-
- > Could someone please help me out, as I'm stuck. From the little I know about
- > awk this should work.
-
- It works on my machine; I think your `awk' may be broken. Why don't you
- try one of the following?
- -------------------------------------------------------------------------------
- gawk '{printf("%s|%5d|%4.1f|%s\n",$1,$2,$3,tolower(substr($0,33)))}' \
- oldfile > newfile
- -------------------------------------------------------------------------------
- awk '{printf("%s|%5d|%4.1f|%s\n",$1,$2,$3,substr($0,33))}' \
- oldfile | tr "[A-Z]" "[a-z]" > newfile
- -------------------------------------------------------------------------------
-
- Daniel Lewart
- d-lewart@uiuc.edu
-