This question will probably be very easy for all you experts but as a newbey I've been driven mad by it.
I have a ksh script and within this I have two variables that contain directory paths SB_HOME and CD. What I want to do is test that CD is under SB_HOME and then fill a third variable BASE with the value of the directory under SB_HOME that contains CD.
For example, if SB_HOME is "/home/mthales/workspace" and CD is "/home/mthales/workspace/Testing/src/level1/sub" then I want BASE to become "/home/mthales/workspace/Testing"
I've got the line if [ -n "$(echo "${CD}" | grep "${SB_HOME}")" ]; then to be able to test that CD is under SB_HOME but I can't get the extraction of the sub string from CD to work. So how could I go about this?
Thanks very much for any help
M
Trainee Chocolate Management Executive.
I have a ksh script and within this I have two variables that contain directory paths SB_HOME and CD. What I want to do is test that CD is under SB_HOME and then fill a third variable BASE with the value of the directory under SB_HOME that contains CD.
For example, if SB_HOME is "/home/mthales/workspace" and CD is "/home/mthales/workspace/Testing/src/level1/sub" then I want BASE to become "/home/mthales/workspace/Testing"
I've got the line if [ -n "$(echo "${CD}" | grep "${SB_HOME}")" ]; then to be able to test that CD is under SB_HOME but I can't get the extraction of the sub string from CD to work. So how could I go about this?
Thanks very much for any help
M
Trainee Chocolate Management Executive.