I'm trying to match filenames that contain two text patterns but the matching process should ignore case. Neither of the following regular expressions work:
Setting the awk variable 'IGNORECASE' to a nonzero value (as recommended in
info awk) so that all regular expression and string operations ignore case, and then building a logical "and" operation using two regular expressions prints all files:
$ ls -R | awk 'IGNORECASE = 1;/bingo/ && /number/;'
I tried converting the data to lowercase before using lookaheads (I know the second lookahead is not needed) to match both the text patterns "bingo" and "number". However awk does not print any output which it should by default 1, 2
$ ls -R | awk 'tolower($0) ~ /(?=.*bingo)(?=.*number)/'
Which part of the awk or regular expression syntax is wrong (or what is missing) and what is the correct way to do a case-independent search that is only successful when the additional pattern appears on the same line?
$ ls -R | awk '/bingo/'
it seems that
awk may be performing the match against the lines in each file in the output of
ls -R due to filenames not containing the string constant "bingo" being matched by
awk. If this is the case, how do you get
awk to have the same behavior as
grep when receiving output from (i.e. sent through) a pipe?