I know I can delete lines that are longer than 100 chars with this:

sed '/^.\{100\}..*/d'

But I have the following example line:

<a href="http://xxxxxxxxxxxxxxx/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx">YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY</a><br>

So I need to only delete the lines where "YYY":


is longer than 100 chars. How can I do this?

I'm using OpenBSD.

grep -vE '">[^<>]{101,}</a><br>'

To remove lines that contain more than 100 non-<> characters between a "> and a </a><br>.


Same as above (if I understand right what you want to do, that is):

sed -e '/Y\{100\}/d'

This matches all lines containing 100 Y in a row, and deletes them.

  • this works too! but the upper "grep" one is more "general" – gasko peter Apr 12 '13 at 6:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.