Date: Thu, 31 Jan 2002 14:21:17 -0300 (ART) From: Fernando Gleiser <fgleiser@cactus.fi.uba.ar> To: =?iso-8859-1?q?adrian=20kok?= <adriankok2000@yahoo.com.hk> Cc: <questions@freebsd.org> Subject: Re: compare two files Message-ID: <20020131141920.J5203-100000@cactus.fi.uba.ar> In-Reply-To: <20020131171616.63549.qmail@web21203.mail.yahoo.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, 1 Feb 2002, adrian kok wrote: > Thanks to Fernando This one-liner shell script will tell you for var in $(cat filea) ; do grep $var fileb; done Fer > > file filea > > ECU > AU > HKG > CA > USA > > > file fileb > > BE > DE > USA > AU > CH > CI > PN > HKG > > > --- Fernando Gleiser <fgleiser@cactus.fi.uba.ar> > wrote: > On Fri, 1 Feb 2002, adrian kok wrote: > > > > > > > > Joel > > > > > > But the diff also outputs the data of fileB > > > > Just grep the part you want. > > > > If the files are similar, you can use diff's unified > > or context format > > man diff for details. > > > > If the files are not similar, and you want to know > > if some random line of > > filea exists in fileb, yo can write a little perl > > script to do the job. > > > > If you tell us the format of the files you want to > > compare, maybe we can > > give you a more detailed answer. > > > > > > Fer > > > > > > > > > > I only need fileA data whether it exists to fileB > > > > > > Thank you > > > > > > > > > --- Joel Dinel <dinjo@touchtunes.com> wrote: > It > > > already exists, and it's called 'diff'. > > > > > > > > man diff > > > > > > > > > > > > On Thu, Jan 31, 2002 at 11:50:13PM +0800, adrian > > kok > > > > wrote: > > > > > Date: Thu, 31 Jan 2002 23:50:13 +0800 (CST) > > > > > From: adrian kok <adriankok2000@yahoo.com.hk> > > > > > Subject: compare two files > > > > > To: freebsd-questions@FreeBSD.ORG > > > > > > > > > > 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 > > > > > > > > > > #!/bin/sh > > > > > $lista=fopen("a.txt", "r"); > > > > > $listb=fopen("b.txt", "r"); > > > > > > > > > > while(!feof($lista)) { > > > > > $dmbuffer = fgets ($lista); > > > > > grep $dmbuffer $listb > diff; > > > > > } > > > > > > > > > > Could you teach me or where can I get this > > > > information > > > > > from website > > > > > > > > > > TIA > > > > > > > > > > > > > > > > > > > > > > > > > _______________________________________________________________________ > > > > > Do You Yahoo!? > > > > > Get your free @yahoo.com.hk address at > > > > http://mail.english.yahoo.com.hk > > > > > > > > > > To Unsubscribe: send mail to > > majordomo@FreeBSD.org > > > > > with "unsubscribe freebsd-questions" in the > > body > > > > of the message > > > > ---end quoted text--- > > > > > > > > -- > > > > Joel Dinel > > > > System Administrator > > > > TouchTunes Digital Jukebox, Inc. > > > > GnuPG key : > > > http://darkhost.mine.nu:81/~joel/misc/mykey.asc > > > > > > > > > _______________________________________________________________________ > > > Do You Yahoo!? > > > Get your free @yahoo.com.hk address at > > http://mail.english.yahoo.com.hk > > > > > > To Unsubscribe: send mail to majordomo@FreeBSD.org > > > with "unsubscribe freebsd-questions" in the body > > of the message > > > > > > > _______________________________________________________________________ > Do You Yahoo!? > Get your free @yahoo.com.hk address at http://mail.english.yahoo.com.hk > To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020131141920.J5203-100000>