title: Date Command in Linux Desktop File Bash Command
body: <p>This is a rather specific question about the date command on linux when it is part of a bash command in a desktop file.</p>
  
  <p><strong>Environment:</strong> ubuntu 16.04</p>
  
  <p>I have a desktop file that executes a bash command that runs a scripts and redirects its output to a dated log file. The bash command itself works fine if run directly from the terminal:</p>
  
  <pre><code>bash -c "/path/to/script &amp;&gt; /var/log/$(date +%Y%m%d).out"
  </code></pre>
  
  <p>The above command creates a file such as <code>/var/log/20190413.out</code>. However, if I use this command as part of a desktop file, the script is run but the output file is not created. This is a sample desktop file:</p>
  
  <pre><code>#!/usr/bin/env xdg-open
  
  [Desktop Entry]
  Version=1.0
  Type=Application
  Terminal=false
  Exec=bash -c "/path/to/script &amp;&gt; /var/log/$(date +%Y%m%d).out"
  </code></pre>
  
  <p>This seems to be specific to the <code>date</code> command. If I replace it in my desktop file with <code>$(hostname)</code>, for instance, it logs to <code>/var/log/&lt;my hostname&gt;.out</code>.</p>
  
  <p>Has anyone encountered this before? Is there something strange happening behind the scenes? <strong>Note:</strong> I'm not looking for a work-around so much as I want to understand what I am doing wrong. Thanks!</p>