I have text file, names.txt, with every row containing a last name:
Smith
Johnson
Morgan
...
...
I’d like to add seven random numbers between 0 and 100 to each line to make it look like this:
Smith 76 94 56 99 32 21 11
Johnson 54 15.2 19.8 32.66 44.99 22.63 18.99
Morgan 99 18.6 24.75 99.22 35.18 65.34 54.22
....
....
I tried using this command in awk:
$ awk '{print $0; for (myvar = 1; myvar <= 7; myvar++) print rand()*100}' names.txt
but that gave me
Smith
76
94
56
etc.
I know I have to use printf, somehow to make it work, and I tried this:
$ awk '{printf $0; for (myvar = 1; myvar <= 7; myvar++) printf rand()*100}' names.txt
but with that, I get no end-of-lines anywhere. The whole thing is just one line.
I’ll very much appreciate any suggestions.
Add line terminator at the end of each line