答案1
所以,这就是我想到的办法。有点混乱,我想可能有更快的方法,但这个办法有效。
for i in $(seq 1 $maxPops); do echo $i; done > output1.txt #make a temp file with numbers 1 to max populations maxPops
awk '{for (i=1;i<=NF;i++) {print "Q"$i;}}' output1.txt > outpu2.txt #Add Q to the beginning of each row name
cut -f1 output2.txt | paste -s > output3.txt #transpose the row names
awk -v OFS="\t" '$1=$1' inputPopFile.txt > chosenPop.txt #change single spaces to tab delimited spaces
cat output3.txt chosenPop.txt > renamedColumns.txt #add formatted column names to desired file chosenPop.txt
rm $fastStructure/temp1.txt $fastStructure/numPops.txt #remove unwanted files