How do I exclude very long lines from grep
results?
I often grep through lots of .js files (-r
) and some of them are compiled, so they consist of a single line usually a couple thousand characters long. From all that clutter I find it hard to see the results from the rest of the files.
What should I pass to grep
to exclude lines that are, say, more than 1000 character long?
I'd prefer not having to pipe the result through another grep, as that would make me lose colours from the output, or having to add the first grep at the end of the pipe again to get back the colours.
cut
but then you'd still lose the colors:grep -r "foo"|cut -c 1000
.