"Gary L. Roach" <garyroach...@gmail.com> writes: > Hi all; > > I have just recently delved into the magical world of Bash scripting > and programmed up the following script(not finished). The object is to > parse the Path and check for the existence of each directory. Please > don't send back an Awk or Sed statement that is more efficient. I am > having enough trouble with the Bash script.
Well, are trying to check the existence of each part of each path element? So for example, first check /Test exists, then /Test/gary, then /Test/gary/run and so on? Because just checking the directories in $PATH is much easier, just read $PATH into an array and iterate over it and you can use test or [ with -d to see if a directory exists. For the weird code you have, well, I avoid bash scripting since I prefer the zsh shell and especially its clearer array syntax. Anyways, for some reason [ A="0 ; " ] is always true. It seems it probably has something to do with expansion, quoting and the special meaning of ;. Changing the line to if [ $A = '0 ; ' ] seems to work.