*BSD News Article 11104


Return to BSD News archive

Received: by minnie.vk1xwt.ampr.org with NNTP
	id AA1255 ; Tue, 23 Feb 93 14:32:32 EST
Xref: sserve comp.unix.bsd:11157 comp.unix.misc:6430 comp.unix.shell:7736 comp.unix.questions:31210
Newsgroups: comp.unix.bsd,comp.unix.misc,comp.unix.shell,comp.unix.questions
Path: sserve!manuel.anu.edu.au!munnari.oz.au!sgiblab!swrinde!cs.utexas.edu!qt.cs.utexas.edu!yale.edu!newsserver.jvnc.net!princeton!tex.Princeton.EDU!subbarao
From: subbarao@fc.hp.com (Kartik Subbarao)
Subject: Re: Splitting a file - HELP WANTED
Message-ID: <1993Feb12.050459.2608@Princeton.EDU>
Originator: news@nimaster
Sender: news@Princeton.EDU (USENET News System)
Nntp-Posting-Host: tex.princeton.edu
Reply-To: subbarao@fc.hp.com
Organization: putchar('I'); for (i = 0; i < 3; i++) putchar('E');
References: <C2B89x.IF6@inews.Intel.COM>
Date: Fri, 12 Feb 1993 05:04:59 GMT
Lines: 31

In article <C2B89x.IF6@inews.Intel.COM> vdalvi@mcd.intel.com (Vishram Dalvi ~) writes:
>Hi Netters,
>
>	Here I am again with another problem. I have two files A and B,
>which contain names of some persons. File B is the subset of file A i.e.,
>
>file A				file B 
>----------------------------------------------
>Bob Miller			Bob Miller	
>Ron Stewart			Simon Bell
>Simon Bell			Jeff Wilson
>Jeff Wilson			Mark Fischer	
>Andy Johnson
>Mick Eastman
>Mark Fischer
>
>	I want to split file A into two parts C and D - one which matches 
>the names in file B and other which doesn't - so that:
>
>file C = (file B)   and	 file D = (file B)'
>
>	What will be the easiest way to do this using awk ? 

Screw awk, if your files are this small.

% fgrep -f filea fileb > filec
(Of course, if order doesn't matter, cp fileb filec)

% fgrep -vf fileb filea > filed

	-Kartik