LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   AIX (http://www.linuxquestions.org/questions/aix-43/)
-   -   Why is my cd command not working? (http://www.linuxquestions.org/questions/aix-43/why-is-my-cd-command-not-working-4175420380/)

cajunchief 08-04-2012 05:06 PM

Why is my cd command not working?
 
I am on an AIX computer ver 5.3.

I am trying to write a script and I get to the part where I want the script to cd to another directory. Why does this command not work?

#!/bin/bash
echo 'What directory are we in? '
pwd
echo 'What directory do you wish to check: ?'
read $DIRPATH
cd $DIRPATH
pwd #this command prints out the current directory that i am in not where the CD commmand should put me?

cajuchief

rknichols 08-04-2012 06:35 PM

Quote:

Originally Posted by cajunchief (Post 4746037)
read $DIRPATH

Leave out the "$" sign there. What is happening is that the shell is substituting the current value (NULL) of DIRPATH there and running the read command with no argument, and whatever you typed in gets assigned to the variable REPLY.

cajunchief 08-04-2012 08:34 PM

Thank you great help
 
THANK YOU FOR ALL YOUR HELP! IT WORKED ! :)


SOLVED


cajunchief

matrix57 08-05-2012 11:15 PM

I have just joined this thread.... I have found this topic really interesting.


All times are GMT -5. The time now is 07:29 AM.