Hi,
I have tried to find some sort of previous similar thread on this but not quite close to what I want to achieve.
Basically I have two class of data in my file..e.g
1,1,1,1,1,2,yes
1,2,3,4,5,5,yes
2,3,4,5,5,5,no
1,2,3,4,4,2,no
1,1,3,4,5,2,no
I wanted to read the "yes" entry to an array and "no" entry into another array.
From there, I wanted to do a random selection of yes[1] or yes[2] to duplicate the existing records.The same goes for no[1],no[2] and no[3].
Could anyone shed some light on this?
I tried some partial solution below but it doesnt work:-
#!/bin/bash
awk -F, ' {
if($NF=="yes"){
i++;
yes=$1;
}
else if($NF=="no"){
j++;
no[j]=$1;
}
}' myfile
I tried to do echo ${yes[@]} and echo ${no[@]} but it doesnt print anything.
Please advise. Thanks.