| Newsgroups |
gmane.editors.sed.user |
| Message-ID |
<[email protected]> |
On 2015-07-05 16:40, 'Ruud H.G. van Tol' [email protected] [sed-users]
wrote:
> On 2015-07-05 16:16, Scott Walters [email protected] [sed-users]
> wrote:
>> 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.
>
> $ perl -E'say $ARGV[0] for 1..$ARGV[1]' abcd 2
> abcd
> abcd
>
> $ echo "abcd 2
> xyz 3" |perl -anE'say $F[0] for 1..$F[1]'
> abcd
> abcd
> xyz
> xyz
> xyz
$ perl -E'while($s=shift){say $s for 1..shift}' abcd 3 xyz 2
abcd
abcd
abcd
xyz
xyz
--
Ruud