Though `sameFile` seems the answer for @RainbowAsteroids, since someone might 
search the forum and wind up here and since my dups example has way more going 
on than necessary for just this and is not standalone, here is how one might do 
a "print sets of referrers" style query: 
    
    
    import os, tables, strutils
    type Id = tuple[device: DeviceId, file: FileId]
    
    proc id2sets(paths: seq[string]): Table[Id,seq[string]] =
      result = initTable[Id, seq[string]](paths.len)
      for path in paths:
        try:
          let fi = getFileInfo(path, followSymlink=false)
          if fi.kind == pcFile:     # skip dirs & symlinks
            result.mgetOrPut(fi.id, @[]).add(path)
        except OSError as e:
          stderr.write "getFileInfo failed on: ",path,": ",
                       e.msg, "\n"
    
    if (let paths = commandLineParams(); paths.len > 0):
      for id, set in paths.id2sets:
        if set.len > 1: echo set.join("\t") # sort in-row?
    else:
      echo "Print hardlink sets for all paths on cmd-line"
    
    
    Run

Exercise for would be user is to extend to `os.walkDirRec` or elsewise.

Reply via email to