Re: egrep question



On Wed, Feb 07, 2007 at 08:13:17AM -0600, Denny Watkins wrote:
I have two files which have titles of books.
I want to check the book titles in one file to see if the title is in the other file.
The book titles have spaces, periods, etc.



I've suggest one simple try

one file is used as list of paterrns grep -f option
and other as list of names to be greped

so something like this

grep -f pattern -v "names"
grep -f pattren names

hope this helps



I wrote a script but I am having a problem getting the title in a form to 'egrep' to the other file.
Titles examples are like:
Tom Sawyer
Tale Of Two Cities


Script is called "check.file.to.file" and is as follows
and is run check.file.to.file name-of-file-1 name-of-file-2

1
2 if [ "$1" = "" ]
3 then
4 arg=0
5 echo "No args..Args are file-name file-to-check"
6 exit
7 else
8 arg=1
9 file1=$1
10 fi
11
12 if [ "$2" = "" ]
13 then
14 echo "Need 2nd argument for file-to-check"
15 exit
16 else
17 file2=$2
18 fi
19
20 # for name in `cat $file1 | cut -f1 -d' '`
21
22 for name in `cat $file1`
23 do
24
25 # egrep -w $name $2 > /dev/null
26 egrep $name $2 > /dev/null
27 grepresult=$?
28
29
30 if (($grepresult == 0))
31 then
32 echo $name " is IN "$2
33 # egrep -w $name $2
34 else
35 echo $name " NOT in "$2
36 fi
37
38 done

Is seems the problem is at line 32. How do you make the $name variable in line 32
quoted?

Thanks,

Denny Watkins
Morningside College
Phone: 712-274-5250

Email: watkins@xxxxxxxxxxxxxxx



Relevant Pages

  • Re: egrep question
    ... Look at the for loop on line 22. ... The book titles have spaces, periods, etc. ... I wrote a script but I am having a problem getting the title in a form to ...
    (AIX-L)
  • Re: egrep question
    ... If you mean display quotes, ... The book titles have spaces, periods, etc. ... I wrote a script but I am having a problem getting the title in a form ...
    (AIX-L)
  • Re: egrep question
    ... The book titles have spaces, periods, etc. ... I wrote a script but I am having a problem getting the title in a form ... Denny Watkins ...
    (comp.unix.aix)
  • egrep question
    ... The book titles have spaces, periods, etc. ... I wrote a script but I am having a problem getting the title in a form ... Denny Watkins ...
    (comp.unix.aix)
  • egrep question
    ... I want to check the book titles in one file to see if the title is in the other file. ... I wrote a script but I am having a problem getting the title in a form to 'egrep' to the other file. ... Denny Watkins ...
    (AIX-L)