How to check if a file exists in a shell script
<p>I'd like to write a shell script which checks if a certain file, <code>archived_sensor_data.json</code>, exists, and if so, deletes it. Following <a href="http://www.cyberciti.biz/tips/find-out-if-file-exists-with-conditional-expressions.html" rel="noreferrer">http://www.cyberciti.biz/tips/find-out-if-file-exists-with-conditional-expressions.html</a>, I've tried the following:</p>

<pre><code>[-e archived_sensor_data.json] &amp;&amp; rm archived_sensor_data.json
</code></pre>

<p>However, this throws an error</p>

<pre><code>[-e: command not found
</code></pre>

<p>when I try to run the resulting <code>test_controller</code> script using the <code>./test_controller</code> command. What is wrong with the code?</p>