Bash: error with cd and path variables

Wednesday, July 9, 2014

Here is the code in question:



path_prefix='opt/copyright_service/gitHub'
while read line
do
user=$line
echo $user
while read line
do
repoName=$line

path="/$path_prefix/$user"

echo $path

cd $path


The output is:



username
/opt/copyright_service/gitHub/username
: No such file or directoryopyright_service/gitHub/username
total 60


Why is it not recognizing the full path in the cd command? Before I added in the user feature I had it reading a repository name from a file, and it did that without a problem, but now that I have it doing both, it doesn't work.


The content of the file it is reading is "username"


I have tried many ways of concatenating $path, by specifying path prefix as cd is called, by concatenating $path_prefix and $user in the cd command(cd /$path_prefix/$user)


Any ideas?







http://ift.tt/1jqegix