title: Bash script - variable content as a command to run
body: <p>I have a Perl script that gives me a defined list of random numbers that correspond to the lines of a file. Next I want to extract those lines from the file using <code>sed</code>.</p>
  <pre><code>#!/bin/bash
  count=$(cat last_queries.txt | wc -l)
  var=$(perl test.pl test2 $count)
  </code></pre>
  <p>The variable <code>var</code> returns an output like: <code>cat last_queries.txt | sed -n '12p;500p;700p'</code>. The problem is that I can't run this last command. I tried with <code>$var</code>, but the output is not correct (if I run manually the command it works fine, so no problem there). What is the correct way to do this?</p>
  <p>P.S: Sure I could do all the work in Perl, but I'm trying to learn this way, because it could help me in other situations.</p>