Artificial intelligent assistant

How to use the shell to delete excess characters conditionally? I don't know if this can be done with simple Unix commands to implement it. Because it looks a bit complicated. I have a text that looks like the following. <p id="mt">Iusto, numquam dolore aut voluptates delectus</p> <p id="mt">Lorem ipsum dolor sit amet</p> <p id="mt">Facere vitae sapiente necessitatibus</p> <p id="mt">Tempora modi rem reprehenderit quam eos. Provident, animi ab ducimus dolorem</p> Each line has different character lengths, and some content is too long and requires omission of excess portions. For example, limit the `<p id="mt">...</p>` content to 20 characters and delete them if you go beyond that. It looks like this. <p id="mt">Iusto, numquam dolor</p> <p id="mt">Lorem ipsum dolor si</p> <p id="mt">Facere vitae sapient</p> <p id="mt">Tempora modi rem rep</p>

Using `sed`:


sed -E 's/^(

.{20}).*(<\/p>$)/\1\2/' infile

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 228583af151c4aecdbba4dd66481b900