Why didn't back quotes in a shell script help me cd to a directory

Viewed 1786

I have a shell script with the following code:

dir=sample
`mkdir $dir`
`cp /home/bhavya/workspace/UnetStack/logs/log-0.txt $dir/log.txt`
`cd $dir`

In the last line with the cd command in the back quotes, I was not able to cd into the corresponding directory. But once I removed the back quotes I was able to cd. What I was wondering is why didn't the cd work with the back quote?

2 Answers
Related