title: Can you expand an environment variable in a file while copying via an RPM spec file?
body: <p>This may be a little awkward question and I don't know if this is possible.</p>
  
  <p>The question is:</p>
  
  <h3><code>file.txt</code></h3>
  
  <pre><code>public class HelloWorld {
     public static void main(String[] args) {
            System.out.println("Hello, ${MY_USERNAME}");
     }
  }
  </code></pre>
  
  <p>I want to club the above file in one of my rpm. The .spec file for the RPM creation will have only below action for this particular file.</p>
  
  <p><code>cp /root/template/file.txt /home/gaur/hello.java</code></p>
  
  <p>Is it possible without using some logic in .spec file (for rpm creation), that when I copy it from <code>/root/template/file.txt</code> to <code>/home/gaur/hello.java</code>, the value in file.txt i.e. <code>${MY_USERNAME}</code> gets replaced by <code>gaur</code>? (by putting something in this <code>file.txt</code>? </p>
  
  <p>Note: I know I can use <code>sed</code> in the <code>.spec</code>, but I am just curious to know if we can have some logic inside <code>file.txt</code>.</p>
  
  <p>Note: The template file in <code>/root/template</code> can be in any language including shell, Python, Perl etc.</p>