1
I need a bash script that will read a file, recognize the delimiter (in case ";") and store the values that are in the delimiters in variables, to later mount a menu with the dialog...
What I’ve done so far is :
#!/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 he reads, is as follows:
Minha Tarefa;/home/;/home/;Diferencial;;N;S;
Minha Tarefa;/home/thalesg;/home/;Diferencial;;N;S;
The output is as follows::
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
Hello friend, I forgot to comment that I managed to solve the problem... I will post the answer
– Tiaurls