I'm trying to make a bash script that run over an array to export documents from a mongo database, but I'm not able to make my index to be incremented.
#!/bin/bash
#script de exportação de documentos das coleções
valores=( 2 4 8 22 40 43 47 48 53 54 55 57 58 60 68 69 74 77 84 86 95 99 107 111 118 122 136 138 139 141 149 150 154 155)
x=0
echo "esse script vai exportar as coisinhas, relaxe e aguarde"
while [ "$x" -lt "${#valores[@]}" ]; do
echo "exportando o documento $x"
mongoexport --db loginapp --collection projetos2017 --query {numInscricao:"${valores[$x]}"} --out premiados2017"$x".json
$x=$((x+1))
done
I've already managed to solve my problem, the dollar sign is not used on variable declaration.
while [ "$x" -lt "${#valores[@]}" ]; do
echo "exportando o documento $x"
mongoexport --db loginapp --collection projetos2017 --query {numInscricao:"${valores[$x]}"} --out premiados2017"$x".json
x=$((x+1))
done