Merge strings with ignore case

I have a bi-lingual database of a large number of dictionaries. It so happens that in some a given string is in upper case and in others it is in lower case. An example will illustrate the issue.

toll Tax=-
Toll tax= 
toll tax=

I want to treat all three instances of

toll tax

as one and map them as under:

toll tax=-, ,

I have an awk script which merges all such mappings, but it fails on instances where lower and upper case are involved
I am giving the script below

#script to merge columns to rows if the LH string is identical
BEGIN{FS="="}
!a[$1]++ {printf RS $1 FS $2 ;next}{printf "," $2}

How do I modify the script such that it will ignore the cases mentioned above and merge all three to

toll tax=-, ,

I could convert the whole database to lower case but that is not feasible since some strings such as Acronyms need to be maintained in uppercase.
My operating system is Windows.
Many thanks for helping out and all good wishes for the New Year.

Hello gimley,

As your haven't provided more sample Input_file, so it is tested with all permutations and combinations.

awk -F'=' 'FNR==NR{A[tolower($1)]=A[tolower($1)]?A[tolower($1)]","$NF:$NF;next} (tolower($1) in A){print A[tolower($1)];delete A[tolower($1)]}'  Input_file  Input_file

Thanks,
R. Singh

1 Like

How about awk 's tolower() ?

!a[tolower($1)]++ {printf RS $1 FS $2 ;next}
1 Like

Thanks to all who helped.
I slightly modified RudiC's script

#script to merge columns to rows if the LH string is identical
BEGIN{FS="="}
!a[tolower($1)]++ {printf RS $1 FS $2 ;next}{printf "," $2}

and it merged all three.
Many thanks to RavinderSingh13 for his help also. The solution he provided worked also