I am trying to write a simple bash script on Ubuntu 12.10 which stores the result of the pwd command in a variable and then checks the value of that variable in an if command to see if it matches a particular string. But I keep getting an error because it treats the content of that variable as a directory itself and keeps giving the error "No such file or directory"
The program is as below:
myvar=$(pwd)
if [$myvar -eq /home/vicky] #fails this check as variable myvar contains /home/vicky
then
echo correct
else
echo incorrect
fi
Any help would be appreciated
$(pwd)or$PWDwould return you the directory from where you are executing the script and not the directory where the script is located?