0
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
4

1 回答 1

2

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

if(toupper($i) == toupper($j)) {
于 2013-05-12T12:38:27.817 回答