If those were exact copy-and-paste from your screen then they don't make sense.
BTW, it's easier to read your stuff if you put it between code tags, that's CODE and /CODE in square brackets like []. If you switch to Advanced mode, there's a # icon that automates it.
You posted that the script was
Code:
directoryName='Test'
echo "directory to change "$directoryName
cd $directoryName
and when run from the command line the output was
Code:
Administrator@neha /cygdrive/c
$ ./file1.sh
directory to change:Test
: No such file or directoryt
/cygdrive/c
First off, the script contains
echo "directory to change "$directoryName and the output from it was
directory to change:Test. Where did the space go and where did the ":" come from?
Secondly, the script contains
cd $directoryName and the output from it was
: No such file or directoryt. Here's what I get when trying to cd to a non-existant directory at the prompt
Code:
c@CW8:~$ cd kdfghjdhfg
bash: cd: kdfghjdhfg: No such file or directory
Where did your
bash: cd go and where did the "t" come from on the end of directoryt?
Thirdly, where did the
/cygdrive/c come from? Is it part of
Administrator@neha /cygdrive/c?
If those were not exact copy-and-pastes from your system then it is difficult for us to help you!
One possibility that might cause the problem is if cd is an alias. You can get the un-aliased cd by escaping it with a "\" as shown below. I've added a couple of lines to the script to help with debugging; please post the output from running this script.
Code:
directoryName='Test'
echo "directory to change "$directoryName
\pwd
/bin/ls
\cd $directoryName