> For the complete documentation index, see [llms.txt](https://til.yulrizka.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://til.yulrizka.com/unix/repeat-content-of-text-x-time.md).

# repeat content of text x time

I have a use-case where 1 have single file that contain 20K line. I need to have another file with 1 million line with just content of the first file repeated 50 time.

Solution: form [stack overflow](http://askubuntu.com/questions/521465/how-can-i-repeat-the-content-of-a-file-n-times)

```
$ perl -0777pe '$_=$_ x 50' input_file.txt > output_file.txt
```

arguments:

* 0777 : -0 sets sets the input record separator (perl special variable $/ which is a newline by default). Setting this to a value greater than 0400 will cause Perl to slurp the entire input file into memory.
* pe : the -p means "print each input line after applying the script given by -e to it".
* $*=$* x 50 : $\_ is the current input line. Since we're reading the entire file at once because of -0700, this means the entire file. The x 50 will result in 50 copies of the entire file being printed.
