title: using hdfs dfs -test to see if directory exists
body: <p>In the hadoop docs:</p>
  
  <pre><code>test
  
  Usage: hadoop fs -test -[defsz] URI
  
  Options:
  
  -d: f the path is a directory, return 0.
  -e: if the path exists, return 0.
  -f: if the path is a file, return 0.
  -s: if the path is not empty, return 0.
  -z: if the file is zero length, return 0.
  Example:
  
  hadoop fs -test -e filename
  </code></pre>
  
  <p>I want to do something if the hdfs directory does not exist.
  Every argument in the <code>-test</code> option returns 0. How can I can an output if a directory does NOT exist? </p>
  
  <pre><code>drwx------   - bli1 hadoop_bips          0 2016-01-29 12:48 /user/bli1/.Trash
  drwx------   - bli1 hadoop_bips          0 2016-01-08 09:41 /user/bli1/.staging
  drwxr-x---   - bli1 hadoop_bips          0 2015-03-31 09:35 /user/bli1/camus_test
  drwxr-x---   - bli1 hadoop_bips          0 2015-11-18 12:41 /user/bli1/hdfs_archive
  drwxr-x---   - bli1 hadoop_bips          0 2016-01-26 16:18 /user/bli1/hdfs_archive_archive
  drwxr-x---   - bli1 hadoop_bips          0 2016-01-26 16:19 /user/bli1/hdfs_archive_concatenate
  drwxr-x---   - bli1 hadoop_bips          0 2016-01-26 16:15 /user/bli1/hdfs_archive_delete
  drwxr-x---   - bli1 hadoop_bips          0 2015-03-31 16:20 /user/bli1/output
  drwxr-x---   - bli1 hadoop_bips          0 2015-03-29 18:09 /user/bli1/wordcount
  </code></pre>
  
  <p>I tried this</p>
  
  <pre><code>$ hdfs dfs -test -d /user/bli1/testdir     # nothing is returned
  $
  $ hdfs dfs -test -d /user/bli1/output      # nothing is returned
  </code></pre>
  
  <p>I am expecting a 0? I see no 0. I don't notice anything different between the 2 commands.</p>