
Fernando F. answered 07/03/19
I can teach you Unix, Database, Perl, Computers
The 'cd' is working in your script and you can see it is so with:
#!/bin/bash
echo `pwd`
cd /home/tree/projects/java
echo `pwd`
The problem with this code is that when the script executes it is executing in a child(subshell) shell where the 'cd' succeeds and when the script ends you are returned to the parent shell and back to the directory in which you were originally in. To make it behave in the way you want you can call it as '. proj' and the script will execute in the current shell and not a subshell.