title: Tell if a file is PDF in bash
body: <p>I need to write a bash script to tell if a file is a pdf file. However, I cannot simply use the file name or extension. </p>
  
  <p>For example:</p>
  
  <p>test.pdf.encrypt - will not open as the file itself is encrypted and the file is of an unknown type the computer can't recognize.</p>
  
  <p>test.pdf.decrypt - will open even though the extension is .decrypt</p>
  
  <p>As looking at the extension does not help and both the encrypted and decrypted file have .pdf in the middle of the name, is there a way to have the system test and see if the file is even readable with a pdf reader?</p>
  
  <p>I just need the command that I can input into an if statement in bash.</p>
  
  <pre><code>if [this file is a working pdf file]; do
     echo "$file is a working pdf file."
  fi
  </code></pre>