egrep question
- From: Denny Watkins <watkins@xxxxxxxxxxxxxxx>
- Date: Wed, 7 Feb 2007 08:13:17 -0600
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 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
- Follow-Ups:
- Re: egrep question
- From: Christopher Baker
- Re: egrep question
- From: Davignon, Edward
- Re: egrep question
- From: Hunter, Mark
- Re: egrep question
- From: Damir Delija
- Re: egrep question
- Prev by Date: Re: Fw: Error - Samba 3.0.4
- Next by Date: Re: egrep question
- Previous by thread: Re: Error - Samba 3.0.4
- Next by thread: Re: egrep question
- Index(es):
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) - Re: egrep question
... I want to check the book titles in one file to see if the title is in the other file.
... one file is used as list of paterrns grep -f option ... I wrote a script
but I am having a problem getting the title in a form to 'egrep' to the other file. ... (AIX-L) - 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)