I know this question has been asked numerous times, but I still could not find any good solution. Hence, asking it again if anyone can help !!
I am trying to change a my working directory inside a shell script with help of a variable. But I get " No such file or directory" everytime.
#!/bin/bash
echo ${RED_INSTANCE_NAME} <-- This correctly displays the directory name
cd $RED_INSTANCE_NAME <-- This line gives the error
Now, when I try to give the actually directory name instead of using the variable, shell changes the directory without issues
cd test <-- No error
Does anyone knows what can be the issue here ? Please help !!
RED_INSTANCE_NAME?cd "${RED_INSTANCE_NAME}"pwdinto your script to validate that the script thinks it's in the right directory; and possible anls -Fas well. What you're doing should work, so it will either be spaces in the directory name, confusion over case, leading/trailing white space (or other unprintable character), or the script isn't running from where you think it's running from.