0

I'm trying to run my first script, just a simple cd reroute.this is the what my file looks like

Unfortunately, I can't seem to get it to work. the script is basically

#!bin/bash
echo "moving you to Desktop"
cd /mnt/c/Users/duanj/Desktop
echo "finished moving"

and both the echo statements end up printing. But no redirect. Also, when I type the cd command in verbatim into my terminal it works.

thejhndwn
  • 9
  • 1
  • why do you think `cd` is not working? , try `cd /mnt/c/Users/duanj/Desktop && echo "cd worked" || echo "cd failed"` – P.... Sep 22 '20 at 01:47
  • what do those additions do? – thejhndwn Sep 22 '20 at 02:01
  • @thejhndwn : I hope you are aware that the working directory is a local property of the process. If you would write `echo "finished moving to $PWD", you would see that PWD has changed; but of course in your calling (parent) process, the working directory is still the same. But if you run your script inside your current process, i.e. by `source SCRIPTNAME`, you avoid creating a child process and the working directory will change in your shell. – user1934428 Sep 22 '20 at 05:33

0 Answers0