#!/usr/bin/env perl
#
# n_repeated_lines - print only lines that repeat n times in one or more files
#
# usage: perl n_repeated_lines.pl [n] [file1.txt] [...]
#
# ---
# source: https://github.com/trizen/perl-scripts

use strict;
use warnings;

my $n = @ARGV && not( -f $ARGV[0] ) ? shift() : 2;

my %seen;
while (<>) {
    /\S/ || next;
    ++$seen{ unpack('A*') } == $n && print;
}
