title: Permission denied while creating directory/file in shell script
body: <p>I have a command in my shell script (increment.sh):</p>
  
  <pre><code>TMP_FILE=/tmp/sbg_clickstream.tmp
  
  hive -e "select * from $HIVE_TMP_TABLE;" &gt; $TMP_FILE
  </code></pre>
  
  <p>I am getting an error on the 2nd line:</p>
  
  <pre><code>/tmp/sbg_clickstream.tmp: Permission denied
  Error: Error occured while opening data file
  Error: Load Failed, records not inserted.
  Load failed (exit code 1)
  </code></pre>
  
  <p>I tried <code>chmod 750 /tmp/sbg_clickstream.tmp</code> and ran the script again but I am still getting the same error.</p>
  
  <p>I am new to shell scripting and I thought the <code>dir/file</code> is created when <code>TMP_FILE=/tmp/sbg_clickstream.tmp</code>. However after the test above,  concluded it does not. </p>
  
  <p>I think the <code>dir/file</code> is created during this line:</p>
  
  <pre><code>hive -e "select * from $HIVE_TMP_TABLE;" &gt; $TMP_FILE
  </code></pre>
  
  <p>How can I change the permissions while the query is populating and creating the file?</p>