I'm trying to know which are the lines that are repeated X times in a text file, and I'm using awk
but I see that awk
in my command, not work with lines that begin with the same characters or words. That is, does not recognize the full line individually.
Using this command I try to get the lines that are repeated 3 times:
awk '++A[$1]==3' ./textfile > ./log
This is what you need hopefully:
Increment array
a
with the line($0
) as index for each line. In the end, for each index ($0
), check if the count(a[i]
which is the originala[$0]
) equals3
. If so, print the line (i
which is the original$0
/ line). Hope it's clear.