I have a problem with variable substitution in bash. I'm doing like as explained in below code, but cd $d is not going into original directory i.e. after expanding $varexport var=/a/b/cfor d \`cat file.f`; docd $ddonefile.f:$var/aa/bb/cc
Bash variable substitution problem
bash;shell script
You need to use eval:export var=/a/b/cfor d in $(cat file.f)do    eval echo $d    eval cd $d    pwddoneor better still, using read:export var=/a/b/cwhile read ddo        eval echo $d        eval cd $d        pwddone < file.f