title: Executing UNIX command using Java
body: <p>I am trying to run Unix find command from Java but it is giving me below error . 
  Please suggest right approach on this -</p>
  
  <blockquote>
    <p>java -cp automation.jar com.amex.scoring.dao.HiveDAO </p>
    
    <p>/bin/sh: find /axp/rim/nemo/dev/logs  -type f -mtime -5 -exec ls {} \;: No such file or directory</p>
  </blockquote>
  
  <p><strong>Java Code</strong></p>
  
  <pre><code>private static final String COMMAND = "find /axp/rim/nemo/dev/logs  -type f -mtime -5 -exec ls {} \\;";
  private static final String SHELL_NAME = "/bin/sh";
  
  public static void main(String[] args) throws IOException {
      final ProcessBuilder pb = new ProcessBuilder(SHELL_NAME,COMMAND);
      pb.redirectErrorStream(true);
      final Process process = pb.start();
      final BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream()));
      String line;
      while ((line = br.readLine()) != null) {
          System.out.println(line);
      }
  }
  </code></pre>