O'Reilly logo

Learning AWK Programming by Shiwang Kalkhanda

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

IGNORECASE

The IGNORECASE variable is used to make the GAWK program case-insensitive or case-sensitive. By default, IGNORECASE is set to 0, making the GAWK program case-sensitive. When we set IGNORECASE to 1, the GAWK program becomes case-insensitive. This has a major affect on regular expression and string comparisons.

In the following example, we are looking for the records containing the string chabra, with a lowercase c in the employee database file emp.dat. However, the last name begins with a capital letter, and hence only chabra is there:

$ awk '/chabra/{print}' emp.dat 

Upon the execution of the preceding code, we will not get any output. Now, we set IGNORECASE to 1, and again print the records containing chabra. It will do a case-insensitive ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required