I have the following function in a bash script:
testcur.sh :
#!/bin/bash
function valcurl {
if [[ $1 != "" ]] then
tbl=$2 # can be multiple values
data=/home/data
btic=$data/$tbl"_btic"
kline=$data/$tbl"_kline"
if [[ "$1" == "btic" ]] then
errbtic=$data/$tbl"_btic_err"
elif [[ "$1" == "kline" ]] then
errkline=$data/$tbl"_kline_err"
fi
# how do I replace the parameter $1 to call the variable?
cat $1 | jq . 2> $"err"$1
if [[ -z $"err"$1 ]] then
echo "correct"
else
echo "contain error"
fi
else
echo "Not var found, only btic or kline"
fi
}
valcurl $1 $2
Is this possible or is there another way?
$erroutand set it to the right filename depending on$1.