title: Best way to find value of a Bash variable in another file without "source"?
body: <p>Without using <code>source</code> to load another Bash config/script file, what is the simplest way to find the value of a Bash variable that is defined in a different (temporary) file?</p>
  
  <p>I have seen similar snippets using <code>cat</code> + <code>while</code>, <code>grep</code>, and even <code>eval</code> but none seem very clean nor can be applied to this scenario it seems...</p>
  
  <p>For example:</p>
  
  <p><code>update.sh</code> wants to download and verify the value of the variable <code>LATEST</code> in a file <code>/tmp/config</code> before deciding if it should proceed with the update process.</p>
  
  <p>Updated (adding more context):</p>
  
  <pre><code>#!/bin/bash
  
  ## current config (includes an existing CONFIG_BUILD variable) ##
  source config
  
  ## compability for updating config ##
  UPDATER_BUILD="FEB2020"
  
  ## retrieve latest version of config online ##
  wget -O /tmp/config http://mirrors.example.com/config-boilerplate
  
  ## ensure retrieved config boilerplate is compatible with current updater ##
  CONFIG_LATEST=$(source /tmp/config; echo $CONFIG_BUILD)
  
  if [[ "$CONFIG_LATEST" != "$UPDATER_BUILD" ]]; then
      echo -e "Sorry, this updater is outdated or incompatible."
      exit 1
  fi
  </code></pre>
  
  <p>Updated (again): FML, I was missing the semicolon in the subshell. So the subshell source does actually work fine without any conflicts despite same VAR name already sourced... all that said, if anyone still can comment with non-source solutions, it would be great. I've searched for days and not many discussions on this topic, although I finally found one:</p>
  
  <p><a href="https://stackoverflow.com/questions/16618071/can-i-export-a-variable-to-the-environment-from-a-bash-script-without-sourcing-i">Can I export a variable to the environment from a bash script without sourcing it?</a></p>