GNU Parallel - Using File with Variable Data within a Script

Asked

Viewed 45 times

0

I would like some help with GNU Parallel.

Is it possible to read variables from a file and pass these variables into a bash script via Parallel? For example: I have a file called dados.txt containing:

maça vermelha
banana amarela
uva verde

And a script lista.sh that needs to read each of these lines as 2 variables: $fruta and $cor

The script would be something like this:

echo Fruta: $fruta
echo Cor: $cor

Thank you

1 answer

0

With the option --colsep da to use the columns of the file as delimiter.

txt data.

maça vermelha
banana amarela
uva verde

sh list.

echo Fruta $1
echo Cor $2

commando

parallel --colsep ' ' ./lista.sh :::: dados.txt

outworking

Fruta maça
Cor vermelha
Fruta banana
Cor amarela
Fruta uva
Cor verde

Browser other questions tagged

You are not signed in. Login or sign up in order to post.