I am facing this issue when concatenating strings Linux shell script
apphome="`cd \`dirname $0\` && pwd && cd - >/dev/null`"
echo "***************** APP Home***************"
echo $apphome
libdir="${apphome}/lib"
echo "**********Lib DIR ***********************"
echo ${libdir}
echo $apphome and echo $libdir gives following output
***************** APP Home***************
/product/abc/project1/cba/STADATA
**********Lib DIR ***********************
/libduct/abc/project1/cba/STADATA
why don't it append /lib to the libdir correctly, could anybody explain me what is going wrong here
shorbash. You're introducing error somewhere that you're not posting.$()nests, backticks do not. Use:$( cd $( dirname $0 ) && pwd )( no need to cd back, it's a subshell) or$( dirname $( readlink -f $0 )). Backticks are evil.