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 Answers2

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
Trevoke
  • 4,115
  • 1
  • 27
  • 48
1

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

cd ~/Desktop
Wug
  • 12,956
  • 4
  • 34
  • 54