В одну сторону:
Содержимое script.awk
:
## In first line, get path and init counter of consecutive paths.
FNR == 1 {
path = $1
repeats = 1
next
}
FNR > 1 {
## If current path is same as previous one, increment counter.
if ( path == $1 ) {
++repeats;
}
## Else, there is new path, so print previous and init counter.
else {
print_repeated_path( repeats, path )
path = $1
repeats = 0
}
}
END {
print_repeated_path( repeats, path )
}
function print_repeated_path(r, path) {
if ( r > 1 ) {
printf "%s\n", path
}
}
Содержимое infile
:
example/example 321
example/example 456
otherexample/otherexample 321
other/example 456
other/example 678
other/example 123
otherexample/otherexample 321
Запустите его как:
awk -f script.awk infile
Со следующим результатом:
example/example
other/example