I have 2 files. One is list file named envlist. Another one is shell script file named test.
In envlist(list file), there's the environment variable list as below ;
setup_top
CFG
those are already declared as the environment variable.
(So when I type cd $setup_top or cd $CFG in command, it works well)
And in test(shell script), there's the code as below ;
#!/bin/bash
dir=$(<$env/envlist) # $env is another environment variable I declared.
for i in ${dir[*]}
do
cd $i # I think this line is a matter.
echo "------------------"
sleep 2
done
When I executed this shell script, I got the error as below;
./test: line 6: cd: setup_top: No such file or directory
----------------------------
./test: line 6: cd: CFG: No such file or directory
----------------------------
reading envlist file line by line seems to work well, but cd command seems not to work.
How can I fix the shell script code to work fine?