perl -ne'y/a//>3|y/b//>2|y/k//>2||print' file # 12345678901234567890123456789012345 # 1 2 3