Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Elegant intersection()
- X-seq: zsh-users 13680
- From: "Gerald Lai" <laigera@xxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Elegant intersection()
- Date: Thu, 8 Jan 2009 16:50:07 -0800
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:mime-version:content-type; bh=5KPcJfSHeiMh9C8wM0VEZPfjptJTbzFFa8JFWSbsvnY=; b=sNtFhgX6mLot8PL/GSSec26ZwSVN5flTEb1aFmPOWn3apdRaJrxllK/GAZ2yoWfBFp eGYWl96LXZzzPS7oRg0jg0ZnVKZauBU5vn46Ij91fSTClfkxUVHlCVrqAi4sv7XWN5VB HuRmCtykKoG2XwQZIdJQiqKzTttWMoj8fJtSk=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:mime-version:content-type; b=Cq9OJqHOVqbwP5CGXsFa9dguOUVr9DgFzzPv/bM9sdVQqSEahk6WUFR3CM4ya08jtQ n+5hdfHbFGhWG01J1T6Xb3jerMVUpgXQyb/0j0ye2JSOsN7C/PviwL9hAIKcNICyh45w +hTB++XiOXuu2rxnNJf54jWZ1ab/su/EcdAGY=
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
To print out lines that are common to 2 files, we can define a function to find the intersection of the lines:
function intersection {sort <(sort -u "$1") <(sort -u "$2") | uniq -d}
To do it for 3 files:
function intersection {sort <(sort -u "$1") <(sort -u "$2") <(sort -u "$3") | uniq -d}
Is there an elegant way to generalize this for "$@" in zsh?
Thanks.
--
Gerald
Messages sorted by:
Reverse Date,
Date,
Thread,
Author