1

I'm trying to make a bash script in which I manipulate a download link with user input dates and such to then download the file. When I run it, it throws an error Final.sh: Line 16: http://real-chart.finance.yahoo.com/table.csv?s=MSFT&a=02&b=13&c=1986&d=02&e=13&f=1986&g=@@d&ignore=.csv: No such file or directory

The second problem is that at the bottom of the code I want the wget "vString" to get the updated (manipulated string) value of the variable but it's taking the original one for some reason. Any advice will help a lot!

Code:

#!/bin/bash
while true; do
vString="http://real-chart.finance.yahoo.com/table.csv?s=MSFT&a=02&b=13&c=1986&d=02&e=13&f=1986&g=@@d&ignore=.csv"
read -p "Escriba el nombre de la empresa: " vEmpresa
read -p "Desea usar un rango de fechas? Y/N? " vRangoBoolean
read -p "Que  tipo de reporte es? " vTipo
if [ $vRangoBoolean == "Y" ]
then
read -p "Escribe el rango de fechas bajo el formato dd/mm/aa - dd/mm/aa:" vRango
elif [ $vRangoBoolean == "N" ]
then
read -p "Escriba el dia: " vDia
read -p "Escriba el mes: " vMes
read -p "Escriba el año: " vAno

${vString/@@d/$vTipo}
${vString/MSFT/$vEmpresa}
${vString/a=02/$vDia}

${vString/02/$vDia}
${vString/13/$vMes}
${vString/1986/$vAno}
${vString/08/$vDia}
${vString/13/$vMes}
${vString/1986/$vAno}
echo "La fecha del documento es: " "$vDia" de "$vMes" del "$vAno"
echo
wget "$vString"
fi
done
1

Shell parameter substitutions like ${string/pattern/replacement} don't modify the original value of string. You need to assign the result of each substitution back to the variable, e.g.

vString="${vString/@@d/$vTipo}"
vString="${vString/13/$vMes}"
vString="${vString/1986/$vAno}"

and so on.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.