W
W
wolverine7772019-10-29 03:42:16
linux
wolverine777, 2019-10-29 03:42:16

How to write a script that makes a table of 2 variables?

Hello, I can’t understand why the final table of 2 variables is not obtained

#!/bin/bash
# Вытаскиваем Name
name=`awk '{print $9}' PMZ_genes.gff3.txt | grep -oP ";\KName=[^;]+" | uniq`

# Каждому набору символов в строке должно соответствовать имя name
for pmz in `awk '{print $9}' PMZ_genes.gff3.txt | cut -c4-14 | uniq`
do
        echo "Symbols $pmz correspond to $name"
done

Each time, the entire name list is repeated, but I would like to get a table of the type:
Symbols PMZ0001 correspond to Name=One
Symbols PMZ0002 correspond to Name=Two
Symbols PMZ0003 correspond to Name=Three
And it turns out while
Symbols PMZ0001 correspond to Name=One
Name=Two
Name=Three
Symbols PMZ0002 correspond to Name=One
Name=Two
Name=Three
I messed up something with the cycles... Please help me figure it out.
Thanks

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Q
q2zoff, 2019-10-29
@wolverine777

names=`awk '{print $9}' PMZ_genes.gff3.txt | grep -oP ";\KName=[^;]+" | uniq`

for pmz in `awk '{print $9}' PMZ_genes.gff3.txt | cut -c4-14 | uniq`
do
        read -r
        echo "Symbols $pmz correspond to $REPLY"
done <<< "$names"

If the number of names is less than the number of entries in the pmz variable, then the process will block, waiting for data from stdin. Also note that the data from the names and pmz variables must match.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question