New feature for 'wc': Filter lines by character count (original) (raw)

I was parsing a log file some days ago, and it had about 1,600,000 lines. All lines in that log file were supposed to have a fix length of say, 140 characters. Because of some noises on RS232 cable, some lines had fewer or much characters than 140.

I was thinking of a program that let me knew how many lines have more/less characters than specified (here 140). I wrote a simple program for my purpose but I thought it is better to integrate this feature in a well-know frequently used tool like 'wc'.

So, the usage would be something like:

$ cat log.txt | wc --more-chars-than 140

9 (for instance)

$ cat log.txt | wc --less-chars-than 140

11 (for instance)

Filtering lines by number of word can also be added.

I read the rejected features for coreutils at http://www.gnu.org/software/coreutils/rejected_requests.html and there was no feature request alike this one. I also searched the mailing list archive and did not find any discussion similiar.