File 1
aaa
ccc
fff
File 2
aaa
bbb
ddd
File 3
aaa
bbb
eee
File 4
bbb
ggg
Output should be:
aaa
bbb
Thank you.
File 1
aaa
ccc
fff
File 2
aaa
bbb
ddd
File 3
aaa
bbb
eee
File 4
bbb
ggg
Output should be:
aaa
bbb
Thank you.
Your question is not clear and explained. Be clear with you question and use code tag.
cat file* | sort | uniq -c | head -2
If you dont want you can remove the count
Thanks for this but I tried it but still it includes the line even it skips a certain file. That is to say,
File 1 - aaa
File 2 - aaa
File 3 - no "aaa"
File 4 - aaa
The output was:
3 aaa
Wherein it should not output the "aaa" because its appearances are not consecutive. Thanks in advance.
How about this..
awk '{a[$0]++} END { for (i in a) { if (a==3) print i}}' file*
EDIT : Ignore this solution. Doesn't meet the "consecutive" requirement you provided.