| Newsgroups |
gmane.editors.sed.user |
| Message-ID |
<[email protected]> |
Method #3:
echo hello | sed -n ':a;/\n\{8\}/q;G;P;ba'
Here we setup a while loop in which the loop break-out condition is that 8 \n are found in the pattern space. If yes, means were done and we promptly quit. Since sed was invoked with -n option, this action of quitting shall generate no output. Otherwise when less than 8 \n were seen in the pattern space, we go ahead and append one more and then using the P command print the string hello and uconditionally branch back to the top of the loop.
[Non-text portions of this message have been removed]