Re: Shell prg for finding occurrance of a string in FILE1 in other file FILE2

From: Anil (anilby_at_gmail.com)
Date: 11/04/04


Date: 3 Nov 2004 23:06:35 -0800

Stephane CHAZELAS <this.address@is.invalid> wrote in message news:<slrncoh7hg.m8.stephane.chazelas@spam.is.invalid>...
> 2004-11-2, 22:33(-08), Anil:
> > Hi,
> >
> > I need a unix bash shell program to accomplish the below task.
> > File1 has some strings one below the other.
> > abcd
> > efgh
> > ijkl
> > mnop
> > qrst
> > uvwx
> > yzab
> >
> > File2 has some strings one below the other.
> > abcd
> > efgh
> > ijkl
> > mnop
> > qrst
> > uvwx
> > yzab
> > abcd
> > efgh
> > ijkl
> > mnop
> > qrst
> > uvwx
> > yzab
> >
> > I need to find whether each strings in File1 are present in File2 or not.
> [...]
>
> Try:
>
> comm -2 -3 <(sort File1) <(sort File2)
>
> grep -xFf File1 File2
>
> awk 'BEGIN{while ((getline < File1) > 0) a[$0]=""} $0 in a}' < File2
>
> (untested)

Thanks for teh responses.



Relevant Pages

  • Re: Shell prg for finding occurrance of a string in FILE1 in other file FILE2

    (comp.unix.shell)
  • Re: Thesaurus
    ... But now I have become stuck with the exporting part. ... I start with ABCD, let a script loop through the records ... and skip the EFGH. ... ABCD might be linked to EFGH, and EFGH linked to IJKL. ...
    (comp.databases.filemaker)
  • Thesaurus
    ... fresh input now. ... I start with ABCD, let a script loop through the records ... and skip the EFGH. ... ABCD might be linked to EFGH, and EFGH linked to IJKL. ...
    (comp.databases.filemaker)
  • Re: Assign an unknown value to an unknown variable
    ... On 8/11/06, Vincent Arnoux wrote: ... efgh = two ... ijkl = three ... I would like to read this file and be able to call variable abcd. ...
    (comp.lang.ruby)
  • Re: operator precedence
    ... [MVP - Microsoft Word] ... FIELD = ABCD ... OR FIELD = EFGH ... The Mail Merge Recipients box shows the ...
    (microsoft.public.word.mailmerge.fields)