Creating duplicate records from a single line

Hi All,
I would like to create a 1 million duplicate records from a single fixed length row. Is there a simple way to create this quickly in unix. I am using korn shell on the AIX OS.

For ex,

100234 XHYSDDS SDSD

OUPUT (1 million rows)

100234 XHYSDDS SDSD
.
.
.
100234 XHYSDDS SDSD

Thanks in advance

Please use code tags for code.

```text
stuff
```
yes "100234 XHYSDDS SDSD" | head -n 1000000
1 Like

Thanks for your quick reply Corona688. But my file length is almost 250 chars and could not copy it in single line. Is there a way can I parameterize the line to feed into yes command.

try

var="100234 XHYSDDS SDSD"
nawk -v var="$var" 'BEGIN { for ( i = 1; i <=1000000; i++ ) { print var}}'
1 Like

Hi mate,
I guess you mean *line* length? If the file has only one long line, you could try this:

yes "`<input.dat`" | head

If it works for you, then run this:

yes "`<input.dat`" | head -n 1000000 > newfile.dat

HTH

1 Like

:slight_smile: Great.. That really helped me a lot. Both the solutions are working fine.. Thank you so much Junior helper and Dodmis..