From owner-svn-src-all@freebsd.org Sat Jun 20 11:27:59 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id BBD0434F01B; Sat, 20 Jun 2020 11:27:59 +0000 (UTC) (envelope-from fernape@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 49pthH4bByz3dDD; Sat, 20 Jun 2020 11:27:59 +0000 (UTC) (envelope-from fernape@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 98D00B95C; Sat, 20 Jun 2020 11:27:59 +0000 (UTC) (envelope-from fernape@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 05KBRx4L097184; Sat, 20 Jun 2020 11:27:59 GMT (envelope-from fernape@FreeBSD.org) Received: (from fernape@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 05KBRxNb097183; Sat, 20 Jun 2020 11:27:59 GMT (envelope-from fernape@FreeBSD.org) Message-Id: <202006201127.05KBRxNb097183@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: fernape set sender to fernape@FreeBSD.org using -f From: =?UTF-8?Q?Fernando_Apestegu=c3=ada?= Date: Sat, 20 Jun 2020 11:27:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r362436 - head/usr.bin/join X-SVN-Group: head X-SVN-Commit-Author: fernape X-SVN-Commit-Paths: head/usr.bin/join X-SVN-Commit-Revision: 362436 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 20 Jun 2020 11:27:59 -0000 Author: fernape (ports committer) Date: Sat Jun 20 11:27:59 2020 New Revision: 362436 URL: https://svnweb.freebsd.org/changeset/base/362436 Log: join(1): Add EXAMPLES section Add EXAMPLES covering options -e, -o, -t, -v, -1 Approved by: 0mp@ Differential Revision: https://reviews.freebsd.org/D25186 Modified: head/usr.bin/join/join.1 Modified: head/usr.bin/join/join.1 ============================================================================== --- head/usr.bin/join/join.1 Sat Jun 20 11:24:29 2020 (r362435) +++ head/usr.bin/join/join.1 Sat Jun 20 11:27:59 2020 (r362436) @@ -31,7 +31,7 @@ .\" @(#)join.1 8.3 (Berkeley) 4/28/95 .\" $FreeBSD$ .\" -.Dd July 5, 2004 +.Dd June 20, 2020 .Dt JOIN 1 .Os .Sh NAME @@ -164,6 +164,78 @@ is the standard input is used. .Sh EXIT STATUS .Ex -std +.Sh EXAMPLES +Assuming a file named +.Pa nobel_laureates.txt +with information about some of the first Nobel Peace Prize laureates: +.Bd -literal -offset indent +1901,Jean Henri Dunant,M +1901,Frederic Passy,M +1902,Elie Ducommun,M +1905,Baroness Bertha Sophie Felicita Von Suttner,F +1910,Permanent International Peace Bureau, +.Ed +.Pp +and a second file +.Pa nobel_nationalities.txt +with their nationalities: +.Bd -literal -offset indent +Jean Henri Dunant,Switzerland +Frederic Passy,France +Elie Ducommun,Switzerland +Baroness Bertha Sophie Felicita Von Suttner +.Ed +.Pp +Join the two files using the second column from first file and the default first +column from second file specifying a custom field delimiter: +.Bd -literal -offset indent +$ join -t, -1 2 nobel_laureates.txt nobel_nationalities.txt +Jean Henri Dunant,1901,M,Switzerland +Frederic Passy,1901,M,France +Elie Ducommun,1902,M,Switzerland +Baroness Bertha Sophie Felicita Von Suttner,1905,F +.Ed +.Pp +Show only the year and the nationality of the laureate using +.Ql <> +to replace empty fields: +.Bd -literal -offset indent +$ join -e "<>" -t, -1 2 -o "1.1 2.2" nobel_laureates.txt nobel_nationalities.txt +1901,Switzerland +1901,France +1902,Switzerland +1905,<> +.Ed +.Pp +Show only lines from first file which do not have a match in second file: +.Bd -literal -offset indent +$ join -v1 -t, -1 2 nobel_laureates.txt nobel_nationalities.txt +Permanent International Peace Bureau,1910, +.Ed +.Pp +Assuming a file named +.Pa capitals.txt +with the following content: +.Bd -literal -offset indent +Belgium,Brussels +France,Paris +Italy,Rome +Switzerland +.Ed +.Pp +Show the name and capital of the country where the laureate was born. +This example uses +.Pa nobel_nationalities.txt +as a bridge but does not show any information from that file. +Also see the note about +.Xr sort 1 +above to understand why we need to sort the intermediate result. +.Bd -literal -offset indent +$ join -t, -1 2 -o 1.2 2.2 nobel_laureates.txt nobel_nationalities.txt | \e + sort -k2 -t, | join -t, -e "<>" -1 2 -o 1.1 2.2 - capitals.txt +Elie Ducommun,<> +Jean Henri Dunant,<> +.Ed .Sh COMPATIBILITY For compatibility with historic versions of .Nm ,