I'm looking for a script (bash, python, perl etc) or even a one liner (sed, awk etc) that can take a set of files and remove any line that has more than "x" instances of any character (case sensitive). I have been doing a lot of searching and can only come up with examples of how to remove blank lines, lines that start with a certain character or lines that contain a certain string.
This will be used on a system running a Kubuntu derivative.
As a very poor and basic example, I would like to take files that contain lines like:
and end up with the files only containing the lines:
if I tell the script that 2 is the maximun number of times any character can appear in any line.
I hope that makes sense.
I know this must be possible, but for the life of me I cannot find even an example that will lead me in the right direction or better yet a piece of code I can use.
Thank you for taking a look at my post and I hope it's not me missing an obvious way of doing this.