Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
find duplicate files
- X-seq: zsh-users 23898
- From: Emanuel Berg <moasenwood@xxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: find duplicate files
- Date: Sat, 06 Apr 2019 07:40:59 +0200
- Cancel-lock: sha1:6Twwb7RuEDsyCcMNG8jc1BCLPAM=
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- List-unsubscribe: <mailto:zsh-users-unsubscribe@zsh.org>
- Mail-copies-to: never
- Mail-followup-to: zsh-users@xxxxxxx
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
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