From owner-freebsd-questions Thu Jan 31 9: 2:20 2002 Delivered-To: freebsd-questions@freebsd.org Received: from moutvdom01.kundenserver.de (moutvdom01.kundenserver.de [195.20.224.200]) by hub.freebsd.org (Postfix) with ESMTP id 04A5837B402 for ; Thu, 31 Jan 2002 09:02:14 -0800 (PST) Received: from [195.20.224.209] (helo=mrvdom02.kundenserver.de) by moutvdom01.kundenserver.de with esmtp (Exim 2.12 #2) id 16WKb8-0007Oc-00; Thu, 31 Jan 2002 18:02:06 +0100 Received: from [80.129.39.238] (helo=there) by mrvdom02.kundenserver.de with smtp (Exim 2.12 #2) id 16WKb7-0007yZ-00; Thu, 31 Jan 2002 18:02:05 +0100 Content-Type: text/plain; charset="iso-8859-1" From: Robert Klein Reply-To: RoKlein@roklein.de Organization: roklein.de To: adrian kok Subject: Re: compare two files Date: Thu, 31 Jan 2002 19:04:41 +0100 X-Mailer: KMail [version 1.3.2] References: <20020131160655.42352.qmail@web21203.mail.yahoo.com> In-Reply-To: <20020131160655.42352.qmail@web21203.mail.yahoo.com> Cc: questions@FreeBSD.ORG MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG > But the diff also outputs the data of fileB > I only need fileA data whether it exists to fileB If your files are lexically ordered, maybe comm(1) is the tool you look for. E.g. comm -23 fileA fileB If your files are not ordered, you can do so, using sort(1) and perhaps uniq(1), too. For example: cat fileA | sort | uniq >fileA.2 cat fileB | sort | uniq >fileB.2 comm -23 fileA.2 fileB.2 >diff-file Please look up the manpages for those commands for further information. Robert > --- Joel Dinel wrote: > > It > > already exists, and it's called 'diff'. > > man diff > > > > On Thu, Jan 31, 2002 at 11:50:13PM +0800, adrian kok wrote: > > > I would like to know how to write script or > > program to > > > compare two file > > > two files: file1 and file2 > > > check data of file1 whether exists in file2 > > > if not > > > write this data in file1 or output to file To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message