Ubuntu – Shell script won’t run cd command

gnome-terminal

I have a text-based game, Colossal Cave Adventure, that I would like to launch with a shell script instead of opening the terminal and typing cd ~/Desktop/CCA and ./Adventure. The code I am trying to use is this:

#! /bin/bash
gnome-terminal -e 'cd ~/Desktop/CCA/; ./Adventure'

and the message i receive is this:

There was an error creating the child process for this terminal
Failed to execute child process `cd` (No such file or directory)

with options to change profile preferences or relaunch the process. I have also tried using the absolute path instead of ~/, and all of my file names are correctly spelled and point to the right place. What is wrong?

Best Answer

cd is a shell builtin. you should use this:

#! /bin/bash
gnome-terminal --working-directory=/home/username/Desktop/CCA/ -e './Adventure'
Related Question