Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

find duplicate files



Is this any good? Can it be done lineary?

TIA

#! /bin/zsh

find-duplicates () {
    local -a files
    [[ $# = 0 ]] && files=("${(@f)$(ls)}") || files=($@)

    local dups=0

    # files
    local a
    local b

    for a in $files; do
        for b in $files; do
            if [[ $a != $b ]]; then
                diff $a $b > /dev/null
                if [[ $? = 0 ]]; then
                    echo $a and $b are the same
                    dups=1
                fi
            fi
        done
    done
    [[ $dups = 0 ]] && echo "no duplicates"
}
alias dups=find-duplicates

-- 
underground experts united
http://user.it.uu.se/~embe8573



Messages sorted by: Reverse Date, Date, Thread, Author