In a bash script I get to this point
read ENE CX CY CZ <<< $(head -n 1 RESULTS_${lach}tal2)
echo $ENE
SED_ARG="-e 's/-/m/g'"
read CX2 <<< $( echo ${CX} | eval sed "$SED_ARG")
read CY2 <<< $( echo ${CY} | eval sed "$SED_ARG")
read CZ2 <<< $( echo ${CZ} | eval sed "$SED_ARG")
DIREC="${CX2}_${CY2}_${CZ2}"
echo $DIREC
cd "$DIREC"
the value of variable DIREC is the name of a directory and I get things like
m25.1240_m22.1250_m5.1540
this directory does exist, and if I do directly in bash cd m25.1240_m22.1250_m5.1540 it works and I can get inside. But on the script it does not work and I get the error:
: No such file or directory: cd: m25.1240_m22.1250_m5.1540
I do not understand why the error
PS:
echo "$DIREC" | od -c
gives
0000000 m 2 5 . 1 2 4 0 _ m 2 2 . 1 2 5
0000020 0 _ m 5 . 1 5 4 0 \r \n
0000033
Does your
RESULTS_${lach}tal2file have windows-style line endings? DoesCZend with a carriage return? What does this show:Additionally, there’s a lot of unnecessary eval’ing going on. Bash can do replacements in variable substitution: