Variable substitution fails for exported variable

January 31, 2018 618 views
Ubuntu 16.04 Linux Commands

While in my home directory, I ran export drt="/var/www/html". I then sourced a script (script 1) that in between other commands, also sources another script (script 2):

find ${drt}/ -type f -iname "*phpmyadmin*" -exec rm -rf {} \;
wget -P ${drt}/

As you can see, the desired state is to download phpmyadmin to the value of drt, which is of course /var/www/html, but instead being downloaded to /var/www/html, it was downloaded to my home directory.

Not only I sourced every script, I exported the variable to have full scope possible just in case, but it seems not to be enough and the ${drt} variable substitution fails.

  • I tried to debug with set -x at the base of the script, but I got no enlighting output.
  • To source a file I use the command source myFile, not any other syntax.
Be the first one to answer this question.