Linux Forums - Linux Help,Advice & support community:LinuxSolved.com

Linux in General => Linux Development & Programming => Topic started by: gregarion on January 14, 2010, 02:55:30 PM

Title: Searching a database
Post by: gregarion on January 14, 2010, 02:55:30 PM
Hey guys, i have a database which is saved as a text file like this
Code:
Code: [Select]
Persia:42:John      ---database
France:50:Mabel
Persia:50:Rach
Germany:60:John
What i am trying to do is to do a search based on two inputs. (1)Title, (2) Author.

Code:

Code: [Select]
echo -n "Title:"
read Title 
echo -n "Author:"
read Author

price_check=`awk  -F: '{if ($1== "$Title" && $3== "$Author" ) print $2 } ' fruit`
echo $price_check
what i am trying to do is that, when i input for example Persia for $Title and Rach for $Author , i would like the code to print the price and save it into a variable and then display it with the echo command.

But for some reason, it is not seem to be working, is there something wrong with my coding?'

hope you guys can suggest other ways in which i can do a search with the two input.
Title: Re: Searching a database
Post by: bilkay on January 20, 2010, 10:47:01 PM
Put single quotes around $Title and $Author (inside the double quotes).