Here's another solution
echo "\
1 hi
2 test
3 try" | awk '{for(i=1;i<=$1;i++){print($2)}}'
output
hi
test
test
try
try
try
This will work the same way, with
awk '{for(i=1;i<=$1;i++){print($2)}}' uniq_counts.txt
The core of the script, if of course
{ for (i=1;i<=$1;i++) { print $2 }
where awk
has parsed the input into 2 fields, $1
being the number (1,2,3) and $2 is the value, (hi,test,try).
The condition i<=$1
tests that the counter i
has not incremented beyond the count supplied in field $1, and the print $2
prints the value each time that i<=$1
condition is true.
IHTH