0

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.

2

2 Answers 2

4

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
1

Use an absolute path or, even better, an environment variable.

cd ~/Desktop

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.