From: Paul Hoffman <nkuitse@nkuitse.com>
To: zsh-users@zsh.org
Subject: Re: find duplicate files
Date: Mon, 8 Apr 2019 10:37:48 -0400 [thread overview]
Message-ID: <20190408143748.GA21630@trot> (raw)
In-Reply-To: <86mul2apj8.fsf@zoho.eu>
On Sat, Apr 06, 2019 at 09:42:51PM +0200, Emanuel Berg wrote:
> zv wrote:
>
> >> Cool, but doesn't seem to work?
> >>
> >
> > Forgot to ignore the second field.
Oops, my bad!
> > #!/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.
> What's with the third line BTW? Looks like
> a comment to me and my editor interprets it that
> way as well.
>
> But changing it to $# doesn't help :(
This might make it clearer:
(( n == 0 )) || echo "n = $n, expected 0"
(( # == 0 )) || echo "# = $#, expected 0"
# 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, and so you can write (( # > 0 )) or (( $# > 0 )) or (( #argv > 0 ))
or (( $#argv > 0 )) all with the same effect.
Paul.
--
Paul Hoffman <nkuitse@nkuitse.com>
next prev parent reply other threads:[~2019-04-08 14:38 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-06 5:40 Emanuel Berg
2019-04-06 13:02 ` Paul Hoffman
2019-04-06 14:44 ` Emanuel Berg
2019-04-06 19:11 ` zv
2019-04-06 19:42 ` Emanuel Berg
2019-04-08 14:37 ` Paul Hoffman [this message]
2019-04-08 14:58 ` Ray Andrews
2019-04-08 15:14 ` Volodymyr Khomchak
2019-04-08 15:24 ` Peter Stephenson
2019-04-08 15:32 ` Andrew J. Rech
2019-04-08 15:47 ` Oliver Kiddle
2019-04-08 16:29 ` Ray Andrews
2019-04-08 16:45 ` Bart Schaefer
2019-04-08 21:30 ` Emanuel Berg
2019-04-09 1:08 ` Jason L Tibbitts III
2019-04-09 1:28 ` Ray Andrews
2019-04-09 9:28 ` Charles Blake
2019-04-08 21:26 ` Emanuel Berg
2019-04-07 11:16 ` Charles Blake
2019-04-07 21:32 ` Bart Schaefer
2019-04-08 11:17 ` Charles Blake
2019-04-08 17:14 ` Bart Schaefer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190408143748.GA21630@trot \
--to=nkuitse@nkuitse.com \
--cc=zsh-users@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).