title: How to distinguish xlsx and docx files from zip archives?
body: <p>I have a use case where I need to know the file type of a file to identify and blacklist the executables(exe,installers etc), archive files(zip, rar etc.). Therefore relying on the extension is not enough for me as the extension of a file can be changed but the file property will remain the same. I tried using the linux command:</p>
  
  <pre><code>file --b filename
  </code></pre>
  
  <p>The above solution is working perfectly with all the file types except the .xlsx and .docx file because the command is giving the following for the .xlsx and .docx</p>
  
  <blockquote>
    <p>Zip archive data, at least v2.0 to extract</p>
  </blockquote>
  
  <p>And because of this I end up blacklisting the .xlsx and .docx file as well.</p>
  
  <p>Can anybody suggest me a way to get the file type without using the extension that works for the xlsx and docx as well.</p>