From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id 813f608b for ; Mon, 8 Apr 2019 21:27:25 +0000 (UTC) Received: (qmail 871 invoked by alias); 8 Apr 2019 21:27:09 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: List-Unsubscribe: X-Seq: 23915 Received: (qmail 15649 invoked by uid 1010); 8 Apr 2019 21:27:09 -0000 X-Qmail-Scanner-Diagnostics: from 195.159.176.226 by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.101.1/25412. spamassassin: 3.4.2. Clear:RC:0(195.159.176.226):SA:0(-1.1/5.0):. Processed in 3.520901 secs); 08 Apr 2019 21:27:09 -0000 X-Envelope-From: gcszu-zsh-users@m.gmane.org X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: none (ns1.primenet.com.au: domain at m.gmane.org does not designate permitted sender hosts) X-Injected-Via-Gmane: http://gmane.org/ Mail-Followup-To: zsh-users@zsh.org To: zsh-users@zsh.org From: Emanuel Berg Subject: Re: find duplicate files Date: Mon, 08 Apr 2019 23:26:23 +0200 Message-ID: <86v9zour28.fsf@zoho.eu> References: <86v9zrbsic.fsf@zoho.eu> <20190406130242.GA29292@trot> <86tvfb9ore.fsf@zoho.eu> <86mul2apj8.fsf@zoho.eu> <20190408143748.GA21630@trot> Mime-Version: 1.0 Content-Type: text/plain User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) Mail-Copies-To: never Cancel-Lock: sha1:T9kpNixxcrI9J/aGA6PIIR4NhA4= Paul Hoffman wrote: >> > #!/bin/zsh >> > find-duplicates () { >> > (( # > 0 )) || set -- *(.N) >> > local dups=0 >> > md5sum $@ | sort | awk '{ print $2,$1 }' | uniq -c -f1 | \ >> > grep -v '^ *1 ' | wc -l | read dups >> > (( dups == 0 )) && echo "no duplicates" >> > } >> >> Still nothing :) > > What were you expecting? It exits with status > 0 if there were no duplicates; otherwise, it > exits with status 1. OK! Yes, it works. Thank you. I put your name next to it in the file [1]. Only I expected it to tell what files are duplicates. Otherwise it isn't so useful :) > # is the name of a variable (a "variable" is > zsh terminology). Its value is the number of > positional parameters, i.e., the number of > elements in $argv. Within (( ... )) you don't > need the dollar sign before a variable name, > but (for the most part) it doesn't hurt to > use it OK, thanks. Better to use the dollar sign so that it doesn't brake the font lock and look like a comment. [1] http://user.it.uu.se/~embe8573/conf/.zsh/files-fs -- underground experts united http://user.it.uu.se/~embe8573