Help with the syntax

export check=$(expandname $(dirname $(which $0)))

The syntax "command1 $(command2)" will run command2 and read the output from it. This output replaces the characters "$(command2)" and then command1 is run and it will see command2's output as its arguments.

$0 is the first word in the command line used to invoke the current script. This is generally the name of the script.

which $0 will search the PATH environment variable for the full pathname of of the script. So if $0 was "myscript", "which myscript" might return something like "/usr/local/bin/myscript".

dirname $(which $0) returns the directory from a pathname. So "dirname /usr/local/bin/myscript" will return just "/usr/local/bin".

expandname $(dirname $(which $0)) Well, expandname is not a standard or even ubiquitous utility. So your expandname may do something I don't know about. But I have seen expandname and the version I have seen makes limited sense here. The expandname I know about will remove environment variables and shell metacharacters from a pathname. So "expandname /usr/l*l/bin" would probably return "/usr/local/bin". However dirname will never return anything that would need expanding. So this is a wasted step or your version of expandname does something different.

check=$(expandname $(dirname $(which $0))) will take the output from expandname and use it to set the variable "check".

export check=$(expandname $(dirname $(which $0))) And finally the variable "check" is exported into the environment. This means that any child processes that we subsequently spawn will be able to see the value of "check". This represents a small violation of a general coding standard... environment variables are usually all caps. So I would have used CHECK.

Thanks for ur help