title: How to use linux commands in bash variables
body: <p>I am trying to create a bash script to perform the same action of the below command :    </p>
  
  <pre><code>dig -x 8.8.8.8 | grep PTR | cut -d ' ' -f 2 | grep google | cut -f 5
  </code></pre>
  
  <p>Output is <code>google-public-dns-a.google.com.</code></p>
  
  <p>Now I have created the script test.sh as below :</p>
  
  <pre><code>#!/bin/bash
  IP=$1
  output1=$(dig -x $IP)
  grepg="grep PTR | cut -d ' ' -f 2 | grep google | cut -f 5"
  go=$($output1 | $grepg)
  echo $go
  </code></pre>
  
  <p>and called the script as ./test.sh 8.8.8.8. But getting errors. How can I store Linux commands inside bash variables effectively with quotes ?<br>
  Thanks</p>