I need a script in bash that reads a file and recognize an delimiter (";") and store the values between the delimiters into variables to build a dialog menu later.
What i've done:
#!/bin/bash
file="Tarefas.cfg"
nomeTarefa=''
dirOrigem=''
dirDest=''
tipoBkp=''
agendarBkp=''
compactarBkp=''
gerarLog=''
echo
for linha in $(cat $file)
do
nomeTarefa=$(echo $linha | cut -d\; -f1 )
dirOrigem=$(echo $linha | cut -d\; -f2 )
dirDest=$(echo $linha | cut -d\; -f3 )
tipoBkp=$(echo $linha | cut -d\; -f4 )
agendarBkp=$(echo $linha | cut -d\; -f5 )
compactarBkp=$(echo $linha | cut -d\; -f6 )
gerarLog=$(echo $linha | cut -d\; -f7 )
echo "$nomeTarefa $dirOrigem $dirDest $tipoBkp $agendarBkp $compactarBkp $gerarLog"
echo
done
the file that it reads is :
Minha Tarefa;/home/;/home/;Diferencial;;N;S;
Minha Tarefa;/home/thalesg;/home/;Diferencial;;N;S;
And the output:
Minha Minha Minha Minha Minha Minha Minha
Tarefa /home/ /home/ Diferencial N S
Minha Minha Minha Minha Minha Minha Minha
Tarefa /home/thalesg /home/ Diferencial N S