Re: File - sed1line.txt

"[email protected] [sed-users]" <[email protected]> 06 Jul 2017 07:14:18 +0000
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]