如何在Linux中将连续区分大小写的单词与awk进行比较?

时间:2013-05-12 12:35:53

标签: linux awk

awk '{
for(i = 1; i <= NF; i++) { 
    j = i + 1;
    if($i == $j) {
        print FNR " | " $0 " | " $i; 
    }
}
}' myfile

如果myfile有这些行:

There is a storm storm outside .

My my car is red .

输出将是:

1 | There is a storm storm outside . | storm

如何使命令忽略区分大小写并显示?

2 | My my car is red . | my

1 个答案:

答案 0 :(得分:2)

你可以使用' toupper '将字符串转换为大写

if(toupper($i) == toupper($j)) {