简体   繁体   中英

IGNORECASE in file comparison with awk

Here is my code:

'FNR==NR {a[$1 FS $2 FS $3 FS $4]++; next} !a[$1 FS $2 FS $3 FS $5]' comparegam.txt workstudyusers1.csv >noidea6.txt

it is doing exactly what I need except I need to ignorecase. I have tried using IGNORECASE=1 in various places but I cant get it to work. it either fails, gives me zero results, or ignores it all together. I tried using BEGIN [IGNORECASE = 1} with no luck.

any help would be appreciated, I am at a lost. I am running this in a terminal window, not from a bash script yet. that is the end goal

Note: Output has to contain case to match original files

Here is the exact code that I have tried with IGNORECASE:

awk -F, 'IGNORECASE=1 FNR==NR {a[$1 FS $2 FS $3 FS $4]++; next} !a[$1 FS $2 FS $3 FS $5]' comparegam.txt workstudyusers1.csv >noidea6.txt
awk -F, 'FNR==NR {IGNORECASE=1} {a[$1 FS $2 FS $3 FS $4]++; next} !a[$1 FS $2 FS $3 FS $5]' comparegam.txt workstudyusers1.csv >noidea6.txt
awk -F, '{IGNORECASE = 1} FNR==NR {a[$1 FS $2 FS $3 FS $4]++; next} !a[$1 FS $2 FS $3 FS $5]' comparegam.txt workstudyusers1.csv >noidea6.txt
awk -F, 'BEGIN {IGNORECASE = 1} FNR==NR {a[$1 FS $2 FS $3 FS $4]++; next} !a[$1 FS $2 FS $3 FS $5]' comparegam.txt workstudyusers1.csv >noidea6.txt
awk -F, 'FNR==NR {{IGNORECASE=1} a[$1 FS $2 FS $3 FS $4]++; next} !a[$1 FS $2 FS $3 FS $5]' comparegam.txt workstudyusers1.csv >noidea6.txt

and various iterations of these.

'
  FNR==NR {
    a[tolower($1 FS $2 FS $3 FS $4)]++;
    next
  }
  !a[tolower($1 FS $2 FS $3 FS $5)]
' comparegam.txt workstudyusers1.csv >noidea6.txt

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM