pwd & cd commands not working in shell script

Here is my script

#!/bin/bash
pwd
cd /var/lib/pgsql

Both "pwd" and "cd" are not executed is there any other way i can change the current working directory to /var/lib/pgsql pls help!

Do you want to change current working directory by running this script? Then run your script as follows

. script_name

Note the space between dot and script_name

I want to display the result of the current working directory in the script how do i do it

Can you explain this? I dont get you.

I want to use the follwing command

pwd in the script but it says command not found after executing

Can you show the exact error message you are getting?

Thanks for helping me actually i was making a very sily mistake as some garbage characters were getting into my script any way thanx a lot

echo $PWD

This will show your present working directory.

Hi i have newly joined this forum .

#!/bin/bash
cd /var/lib/pgsql