title: Change gunzip temporary directory while used in pipe
body: <p><strong>Background</strong></p>
  
  <p>I'm working on an mysql server with those hdd partitions:</p>
  
  <pre><code>...
  /dev/vdd       99G     58G   39G   61% /var/lib/mysql
  tmpfs         2,4G       0  2,4G    0% /tmp
  ...
  </code></pre>
  
  <p>I need to import a mysql dump into my database. Therefore I use the following syntax:</p>
  
  <pre><code>gunzip -c sql_dump.sql.gz | mysql -uDB_USER -p DB_NAME
  </code></pre>
  
  <p>In general this works but my <code>sql_dump.sql.gz</code> file will be over 5GB when extracted. </p>
  
  <p>The command above will fail with <code>gzip: /home/.../sql_dump.sql.gz: No space left on device</code>. I think this is not related to the <code>mysql</code> partiton which has enough space, but the <code>/tmp</code> partition which does only have 2.4GB free.</p>
  
  <p>For now I did go ahead an moved the file to the <code>/var/lib/mysql</code> parition which has enough free space. gunzip my file there, start the mysql import and removed the compressed and uncompressed files afterward.</p>
  
  <p><strong>Question</strong></p>
  
  <p>I was asking myself if there is any way I can force <code>gunzip</code> to temporary change the default temporary target location, which is <code>/tmp/</code> by default. So that <code>gunzip -c sql_dump.sql.gz | ...</code> does not store the extracted file under <code>/tmp/</code> but under <code>/var/lib/mysql</code> while extracting the file. Something like this:</p>
  
  <pre><code>export "GZIP_TMP_DIR=/var/lib/mysql/"
  gunzip -c sql_dump.sql.gz | mysql -uDB_USER -p DB_NAME
  </code></pre>
  
  <p>Is this even possbile ? I searched a lot but could not find anything that would solve this specific need.</p>