/usr/bin/s9dupes is in scheme9 2017.11.09-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | #! /usr/bin/s9 -f
; dupes -- find duplicate file names
; by Nils M Holm, 2010
; Placed in the Public Domain
;
; Usage: dupes [directory]
(load-from-library "hof.scm")
(load-from-library "hash-table.scm")
(load-from-library "string-split.scm")
(load-from-library "basename.scm")
(load-from-library "parse-optionsb.scm")
(load-from-library "displaystar.scm")
(define readable-output (option #\r #f))
(define show-help (option #\h #f))
(define options `(,readable-output
,show-help))
(define (usage)
(display "Usage: dupes [-r] [file ...]")
(newline))
(let* ((files (parse-options! (sys:command-line) options usage))
(files (if (null? files) '(".") files))
(found (make-hash-table))
(first #t)
(list-dupes
(lambda (readable)
(for-each (lambda (set)
(if (> (length set) 2)
(begin (if first
(set! first #f)
(if readable
(newline)))
(if readable
(display* (car set) ":")
(display (car set)))
(for-each (lambda (loc)
(if readable
(display* #\newline loc)
(display* #\space loc)))
(cdr set))
(newline))))
(hash-table->alist found)))))
(if (opt-val show-help)
(begin (display-usage
`(""
,usage
""
"Find duplicate directory entries"
""
"-r print human-readable output"
""))
(sys:exit 0)))
(let loop ((files files))
(let* ((path (if (null? files)
"ignore"
(car files)))
(name (basename path)))
(cond ((null? files)
(list-dupes (opt-val readable-output)))
((sys:lstat-directory? path)
(loop (append (map (curry string-append path "/")
(sys:readdir path))
(cdr files))))
((sys:lstat-symlink? path)
(loop (cdr files)))
((hash-table-ref found name)
=> (lambda (refs)
(hash-table-set! found name (cons path (car refs)))
(loop (cdr files))))
(else
(hash-table-set! found name (list path))
(loop (cdr files)))))))
|