Here is my script to change the directory
[user@linux ~]$ cat script.sh
echo Before: $(pwd)
cd "$1"
echo After : $(pwd)
[user@linux ~]$
When I tested it, it did not really change the directory as shown in the last pwd
command.
Manual pwd
command
[user@linux ~]$ pwd
/home/user
[user@linux ~]$
Test 1
[user@linux ~]$ script.sh dir01/
Before: /home/user
After : /home/user/dir01
[user@linux ~]$
Test 2
[user@linux ~]$ script.sh /home/user/dir01
Before: /home/user
After : /home/user/dir01
[user@linux ~]$
Manual pwd
command again after that
[user@linux ~]$ pwd
/home/user
[user@linux ~]$
What's wrong with my code?