title: How to collect directory listing along with each file CRC checksum?
body: <p>I use the following command to get dir listing in nix(Linux, AIX, Sunos, HPUX) platforms</p>
  
  <p>Command</p>
  
  <pre><code>ls -latr 
  </code></pre>
  
  <p>Ouput</p>
  
  <pre><code>drwxr-xr-x  2 ricky support   4096 Aug 29 11:59 lib 
  -rwxrwxrwx  1 ricky support    924 Aug 29 12:00 initservice.sh
  </code></pre>
  
  <p><code>cksum</code> command is used for getting CRC checksum.</p>
  
  <p>How can the CRC Checksum be appended after each file something (including directory listing too) like below, maintaining the below format in these nix(Linux, AIX, Sunos, HPUX) platforms?</p>
  
  <pre><code>drwxr-xr-x  2 ricky support   4096 Aug 29 11:59 lib 
  -rwxrwxrwx  1 ricky support    924 Aug 29 12:00 initservice.sh 4287252281
  </code></pre>
  
  <p><strong>Update Note</strong> : No third party application, I am using java/Groovy to parse the output ultimately into a given format which forms a xml using groovy XmlSlurper (XML's get generated around 5MB sized)</p>
  
  <pre><code>"permission","hardlink","owner","group","fsize","month","date","time","filename","checksum"
  </code></pre>
  
  <p>All Suggestions are welcome! :)</p>
  
  <p><strong>Update with my code</strong></p>
  
  <p>But here I am calculating md5hex which gives a similar output as <code>md5sum</code> command from linux. So it's no longer <code>cksum</code> as I cannot use jacksum bcz of some licensing issue :(</p>
  
  <pre><code>class CheckSumCRC32 {
  
  public def getFileListing(String file){
      def dir = new File(file)
      def filename = null
      def md5sum = null
      def filesize = null
      def lastmodified = null
      def lastmodifiedDate = null
      def lastmodifiedTime = null
      def permission = null
      Format formatter = null
      def list=[]
      if(dir.exists()){
          dir.eachFileRecurse (FileType.FILES) { fname -&gt;
              list &lt;&lt; fname
            }
          list.each{fileob-&gt;
              try{
                  md5sum=getMD5CheckSum(fileob.toString())
                  filesize=fileob.length()+"b"
                  lastmodified=new Date(fileob.lastModified())
                  lastmodifiedDate=lastmodified.format('dd/MM/yyyy')
                  formatter=new SimpleDateFormat("hh:mm:ss a")
                  lastmodifiedTime=formatter.format(lastmodified)
                  permission=getReadPermissions(fileob)+getWritePermissions(fileob)+getExecutePermissions(fileob)
                  filename=getRelativePath("E:\\\\temp\\\\recurssive\\\\",fileob.toString())
                  println "$filename, $md5sum, $lastmodifiedDate, $filesize, $permission, $lastmodifiedDate, $lastmodifiedTime "
              }
              catch(IOException io){
                  println io
              }
              catch(FileNotFoundException fne){
                  println fne
              }   
              catch(Exception e){
                  println e
              }           
          }
      }       
  }
  
  public def getReadPermissions(def file){
      String temp="-"
      if(file.canRead())temp="r"
      return temp
  }
  public def getWritePermissions(def file){
      String temp="-"
      if(file.canWrite())temp="w"
      return temp
  }
  public def getExecutePermissions(def file){
      String temp="-"
      if(file.canExecute())temp="x"
      return temp
  }
  public def getRelativePath(def main, def file){""
      return file.toString().replaceAll(main, "")
  }
  
  
  public static void main(String[] args) {
      CheckSumCRC32 crc = new CheckSumCRC32();
      crc.getFileListing("E:\\temp\\recurssive")
  }
  }
  </code></pre>
  
  <p>Output</p>
  
  <pre><code>release.zip, 25f995583144bebff729086ae6ec0eb2, 04/06/2012, 6301510b, rwx, 04/06/2012, 02:46:32 PM 
  file\check\release-1.0.zip, 3cc0f2b13778129c0cc41fb2fdc7a85f, 18/07/2012, 11786307b, rwx, 18/07/2012, 04:13:47 PM 
  file\Dedicated.mp3, 238f793f0b80e7eacf5fac31d23c65d4, 04/05/2010, 4650908b, rwx, 04/05/2010, 10:45:32 AM 
  </code></pre>
  
  <p>but still I need a way to calculate hardlink, owner &amp; group. I searched on the net it looks like <a href="http://docs.oracle.com/javase/7/docs/api/java/nio/file/package-summary.html" rel="nofollow">java7</a> has this capability &amp; I am stuck with java6. Any help?</p>