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}/ https://www.phpmyadmin.net/downloads/phpMyAdmin-latest-all-languages.zip

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.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

1 answer


I tried to test this at my end and it worked as expected.

What is the default shell that you are using? You could check that with:

echo $SHELL

If you are not using BASH, maybe try setting your shell to BASH and test this again.


Submit an Answer