Re: print N times

"Jim Hill [email protected] [sed-users]" <[email protected]>
Newsgroups gmane.editors.sed.user
Message-ID <CAEE75_2bcGJWyNKjs4k3nH9FdsLNW_hQxNGpHFKcrFgN2UzmNA@mail.gmail.com>
I think Thierry's got the right answer (to keep sed in the picture I'd
replace `head -n 4` with `sed 4q`) but if you want a repeater in pure sed
you can

   N=3; sed -E ":a;h;  s/((\n[^\n]*){$((N-1))}).*/\1/;  t;G;ba"

on GNU/anything, I dunno whether the {0} stunt for N=1 works on other seds.

On Sun, Jul 5, 2015 at 7:16 AM, Scott Walters [email protected]
[sed-users] <[email protected]> wrote:

>
>
> Hello,
> A  theoretical question.echo  abcd |  sed 'p;p;p'      prints the word
> "abcd" 4 times.Is there a simpler way to print a word N times ( N=large
> number) by NOT using the "p" command N-1 times.it has to be simple like
> we use in a regular for loop.
> thanksScott W
>
> [Non-text portions of this message have been removed]
>
>  
>


[Non-text portions of this message have been removed]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.