title: Assigning output of a command to a variable(BASH)
body: <p>I need to assign the output of a command to a variable. The command I tried is:</p>
  
  <pre><code>grep UUID fstab | awk '/ext4/ {print $1}' | awk '{print substr($0,6)}'
  </code></pre>
  
  <p>I try this code to assign a variable:</p>
  
  <pre><code>UUID=$(grep UUID fstab | awk '/ext4/ {print $1}' | awk '{print substr($0,6)}')
  </code></pre>
  
  <p>However, it gives a syntax error. In addition I want it to work in a bash script.</p>
  
  <p>The error is:</p>
  
  <pre><code>./upload.sh: line 12: syntax error near unexpected token ENE=$( grep UUID fstab | awk '/ext4/ {print $1}' | awk '{print substr($0,6)}'
   )'
  
  ./upload.sh: line 12:   ENE=$( grep UUID fstab | awk '/ext4/ {print $1}' | awk '{print substr($0,6)}'
   )'
  </code></pre>