Say my input file is tab delimited, how do i identify if $0 contains a word “hello” and it needs to be case insensitive?
here is a hello whateverColumn2
nonono nonono whateverItIs
here HeLLo again mockColumn2
Thanks a lot!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Given your lines in file
data.txt:will print
The
-F"\t"sets tab as the field separator for the input lines.Update (based on request in comments below by OP):
To make this case-insensitive use the
IGNORECASEflag:Note that the IGNORECASE variable is a GNU extension and may not be available in other versions of AWK.
Alternatively, an example using
match. In order to make this case-insensitive, the input is converted into lower case:Since match can take regular expressions, the conversion to lowercase may not be necessary with the right regular expression.
Tested with GNU Awk 3.1.6 under Linux