Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to use IGNORECASE variable?

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hi all,

Can someone show me how the IGNORECASE variable works? I need to write a script that matches for instance the word "the", knowing that this word can also start with a capitalized letter, so "The".

Thanks,

W
 
Hi,

The IGNORECASE option is only avalaible with gawk.
The man page says :
[ul][li]
IGNORECASE
Controls the case-sensitivity of all regular expression and string operations.
If IGNORECASE has a non-zero value, then string comparisons and pattern matching in rules, field splitting with FS, record separating with RS, regular expression matching with ~ and !~, and the gensub(), gsub(), index(), match(), split(), and sub() pre-defined functions will all ignore case when doing regular expression operations.
Thus, if IGNORECASE is not equal to zero, /aB/ matches all of the strings "ab", "aB", "Ab", and "AB".
As with all AWK variables, the initial value of IGNORECASE is zero, so all regular expression and string operations are normally case-sensitive.
Under Unix, the full ISO 8859-1 Latin-1 character set is used when ignoring case.
NOTE: In versions of gawk prior to 3.0, IGNORECASE only affected regular expression operations. It now affects string comparisons as well.
[/li][/ul]

With others implementation of awk you must write :

awk '/[Tt]he/' input_file

Jean Pierre.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top