0
I have the following problem: I copied the data from an Internet table into a text file. The goal is to turn this file to the default. csv in English (comma separated and decimal separator being the endpoint) plus some other formatting. Example of file:
Data Fechamento Variação Variação (%) Abertura Máxima Mínima Volume
30 Abr 2020 2,00 0,76 61,29% 1,99 2,10 1,80 152.100
29 Abr 2020 1,24 -0,44 -26,19% 1,28 1,71 1,20 125.700
My code is like this:
echo -e "Arquivo nao-estruturado: \c"
read nome_arq
arq=$(<$nome_arq)
arq=$(echo $arq | sed 's/%//g')
arq=$(echo $arq | sed 's/()//g')
arq=$(echo $arq | sed 's/\.//g')
arq=$(echo $arq | sed 's/\+//g')
arq=$(echo $arq | sed 's/ Abr /_04_/g')
arq=$(echo $arq | sed 's/ Mar /\_03_/g')
arq=$(echo $arq | sed 's/\,/\./g')
arq=$(echo $arq | sed 's/\ /\,/g')
append="_clean"
echo -e $arq >> $nome_arq$append
However, the script output is not line breaking, that is, the output file only contains a single line:
Data,Fechamento,Variação,Variação,Abertura,Máxima,Mínima,Volume,30_04_2020,2.00,0.76,61.29,1.99,2.10,1.80,152100,29_04_2020,1.24,-0.44,-26.19,1.28,1.71,1.20,125700,
Ideas for the original file lines to stay in the output file?
It worked perfectly, beast, thank you!
– Danusio Gadelha Filho