Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!ucbvax!ucdavis!caldwr!rfinch From: rfinch@caldwr.UUCP (Ralph Finch) Newsgroups: comp.unix.questions Subject: Re: cascading pipes in awk Summary: upper to lower case Keywords: awk Message-ID: <496@caldwr.UUCP> Date: 25 May 89 15:12:20 GMT References: <813@manta.NOSC.MIL> Distribution: usa Organization: California Department of Water Resources Lines: 41 In article <813@manta.NOSC.MIL>, psm@manta.NOSC.MIL (Scot Mcintosh) writes: > Is there a way to cascade pipes in awk? I'm trying to do something > like the following: > { print | "tr [a-z] [A-Z]" | < now-upper-case text >> > } > > Any other suggestions to accomplish the same thing would be > appreciated. I'm also frustrated that awk doesn't allow the use of Unix utilities inside of awk. I had a similar problem that Scot did (only I wanted to go from upper to lower case). Here was my solution: name_up="UPPERCASENAME" # create upper-to-lower table for (i=65;i<=90;i++) { up=sprintf("%c",i) lw=sprintf("%c",i+32) alpha[up]=lw } # preserve punctuation characters for (i=32;i<=64;i++) { c=sprintf("%c",i) alpha[c]=c } for (i=91;i<=126;i++) { c=sprintf("%c",i) alpha[c]=c } # translate the name from upper-to-lower case name_low="" for (i=1; i<=length(name_up); i++) name=name""alpha[substr(name_up,i,1)] -- Ralph Finch ...ucbvax!ucdavis!caldwr!rfinch