Solução GNU estendida AWK
:
Amostra inputfile
contents:
RamaKrishna KrishnaRama
IndiaUS USIndia
UkraineMotherland RepublicUkraine
awk 'BEGIN{ PROCINFO["sorted_in"]="@str_val_asc" }
{
len=split($1,w1,""); split($2,w2,""); asort(w1); asort(w2); not_eq=0;
for (i=1; i<=len; i++) if (w2[i]=="" || w1[i] != w2[i]) { not_eq=1; break }
print $0,"-",(not_eq? "not equal":"equal")
}' inputfile
A saída:
RamaKrishna KrishnaRama - equal
IndiaUS USIndia - equal
UkraineMotherland RepublicUkraine - not equal