explanation for this line

Hi All,

can you please explain me the meaning of this line--

BackupLocation="/inpass/abc"
Parent=$(expr $BackupLocation : '\(.*\)/.*' \| $BackupLocation)

when i ran this as a command also it did not show me anything so could not get the purpose of this line.

Explain it please.

Here is the ouput under ksh93

$ BackupLocation="/inpass/abc"
$ echo $BackupLocation
/inpass/abc
$ Parent=$(expr $BackupLocation : '\(.*\)/.*' \| $BackupLocation)
$ echo $Parent
/inpass
$

Note that dirname outputs the same result

$ dirname /inpass/abc
/inpass

It is an attempt to set the variable Parent. You need to follow it with
echo $Parent
to see anything. Basicly, it strips off a trailing slash followed by some characters. Should the regular expression not match, it just returns the input variable. It will stumble if BackupLocation is set to something like "/abc" which matches the regular expression without returning anything. But that input may not be likely. My preferred solution
Parent=${BackupLocation%/*}
would have the same trouble. A better solution might be:
Parent=$(dirname $BackupLocation)
which should work all the time.

Thanks Guys for all your valuable comments.I got it now.

Thanks
Namish