Reputation:
I made a shell script that I want wherever it is to go to a directory. For example if the shell is in Downloads I want it to go to Desktop create there a folder go to that folder and many other thing but CD command does not work.
#!/bin/bash
cd Desktop
It says so:
setup.sh: 2: cd: can't cd to Desktop
I there a way to use it, please help.
Upvotes: 0
Views: 3339
Reputation: 13196
Use an absolute path or, even better, an environment variable.
cd ~/Desktop
Upvotes: 1
Reputation: 4117
The 'cd' command is working great. It's telling you there's no 'Desktop' directory.
You need to provide a relative or absolute path to where that 'Desktop' directory is:
#!/bin/bash
cd ~/Desktop
cd /home/user/some/subdir/here/Desktop
Upvotes: 4