schriste@uceng.UC.EDU (Steven V. Christensen) (11/28/90)
Hi, I'm writing an AWK script which must search for the occurrance of user-specified text. Right now it is: /text/ {do something} But I need /text/ to be case insensitive. What do I need to do? Thanks, Steven the neophyte. -- Steven V. Christensen U.C. College of Eng. schriste@uceng.uc.edu For the adventurous: svc@elf0.uucp
arnold@audiofax.com (Arnold Robbins) (11/30/90)
In article <6801@uceng.UC.EDU> schriste@uceng.UC.EDU (Steven V. Christensen) writes: >Hi, I'm writing an AWK script which must search for the occurrance of >user-specified text. Right now it is: > >/text/ {do something} > >But I need /text/ to be case insensitive. What do I need to do? There are several options. The most portable is to put your awk program into a pipeline on the other end of tr. Assuming a System V tr tr '[A-Z]' '[a-z]' < data | awk '/text/ { stuff }' # use tr A-Z a-z on a BSD system where your text is in lower case. If you have the very latest at&t nawk (available from the ATT Toolchest), you can use the tolower() built-in function to map your data into one case, like so: { $0 = tolower($0) } /text/ { stuff } If you have or can get gnu awk, you set IGNORECASE=1 in a BEGIN block or on the command line, and the regexp match will be done ignoring case. Gnu awk also supports the tolower and toupper functions. If you don't wish to use the tr example, those are your next best bet. -- Arnold Robbins AudioFAX, Inc. | Laundry increases 2000 Powers Ferry Road, #200 / Marietta, GA. 30067 | exponentially in the INTERNET: arnold@audiofax.com Phone: +1 404 933 7612 | number of children. UUCP: emory!audfax!arnold Fax-box: +1 404 618 4581 | -- Miriam Robbins