Combining a search with database.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Combining a search with database.
# 1  
Old 01-07-2010
Combining a search with database.

Code:
function press_1
{
Number=
echo -n "Title : "
read number
if [ "$number" = grep "$number" Hello1 ]; -- line 12
 then
echo  "smelly"
else 
echo "already exist"
fi  
}

For this coding, what i have done is to enter a title. then in line 12 , i did a if statement which is suppose to search the text file Hello1 , and if the title appears before, it will output the word "smelly". when i tried running it, i got back an error message

./Bookshop: line 12: [: too many arguments

what does this mean? and how can i go about solving it?

Last edited by Scott; 01-07-2010 at 11:01 AM.. Reason: Code tags, PLEASE
# 2  
Old 01-07-2010
You should use something like:
Code:
if [ "$number" = "$(grep "$number" Hello1)" ]
then

Which would work is Hello1 is a file that contains one number/title per line,

or just:
Code:
if grep -q "$number" Hello1
then

# 3  
Old 01-07-2010
okay , when i tried the 2nd coding, it still states the same error.

For Code 1
Code:
#!/bin/bash
selection=
echo "title " 
read number
if [ "$number"  =  "$(grep "$number" Hello1)" ] ; then
echo "helo"
fi

For the first coding , i tried adding the all the signs and brackets, but it does not seem to work. and the "grep" color turns pink. why is that? the error i got this time was :
Command not found in line

---------- Post updated at 11:20 PM ---------- Previous update was at 11:16 PM ----------

Actually, i got it. forgot to take out the brackets when trying the first coding. thanks alot! nice to know there are people out here to help beginners like me.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Combining 2 commands

Hello all, I need to send an attachment and text in the body, both in the same Email. Below are two cammand that send the required data in separate Emails. I need to combine them so that I get just 1 Email containing the attachment & text in the body. uuencode ${filename} "${file_}" |... (6 Replies)
Discussion started by: Junaid Subhani
6 Replies

2. Shell Programming and Scripting

Parse through ~21,000 Database DDL statements -- Fastest way to perform search, replace and insert

Hello All: We are looking to search through 2000 files with around 21,000 statements where we have to search, replace and insert a pattern based on the following: 1) Parse through the file and check for CREATE MULTISET TABLE or CREATE SET TABLE statements.....and they always end with ON... (5 Replies)
Discussion started by: madhunk
5 Replies

3. Shell Programming and Scripting

CRON Job to copy database and replace existing database

I have a reseller account with hostgator, which means i have WHM and Cpanel. I have set up a staging environment for one of my wordpress installations (client website), which is essentially sitting at staging.domain.com (live site is at domain.com). The staging website is a complete copy of the... (1 Reply)
Discussion started by: nzrobert
1 Replies

4. Shell Programming and Scripting

combining two images into one

Hi, I have two sets of image files. Both sets have names A to Z but set 1 ends with .cdt.png and set 2 ends with .matrix.png. I want set 1 to match with set 2 if the names match (i.e. A.cdt.png will match with A.matrix.png) and with the convert image tool (program for images), it will merge the... (1 Reply)
Discussion started by: kylle345
1 Replies

5. Solaris

Can't create database after Oracle Database installation

I installed Oracle 10 software on Solaris 11 Express, everything was fine execpt I can't create database using dbca.rsp file. I populated file with following options. OPERATION_TYPE = "createDatabase" GDBNAME = "solaris_user.domain.com" SID = "solaris_user" TEMPLATENAME = "General... (0 Replies)
Discussion started by: solaris_user
0 Replies

6. Shell Programming and Scripting

combining two lists

Hi, So I I received two lists for my merchandise and both are similar but differences do occur. I want to combine two lists that have similar names but I dont want the similar name to come up twice because I will end up purchasing two of those items. Heres an example below (file is massive). ... (1 Reply)
Discussion started by: kylle345
1 Replies

7. Solaris

redirect solaris database from linux database..

hi.. i have a need .. my php runs on my linux redhat box with mysql.. i want my php code to refer another mysql database which is in solaris 10 x86... can u tell me the procedure .. how it can be done through php .. sorry am new to php... is it possible to redirect from linux mysql to... (7 Replies)
Discussion started by: senkerth
7 Replies

8. Shell Programming and Scripting

Combining Two Files

Could someone help me reduce the number of runs for a shell program I created? I have two text files below: $ more list1.txt 01 AAA 02 BBB 03 CCC 04 DDD $ more list2.txt 01 EEE 02 FFF 03 GGG I want to combine the lines with the same number to get the below: 01 AAA 01 EEE 02... (4 Replies)
Discussion started by: stevefox
4 Replies

9. UNIX for Advanced & Expert Users

Combining makefiles

I have concatenated 2 makefiles, to produce 1 however it is not running all of the code, producing a fatal error: symbol referencing errors. No output written. Can anybody please help? (4 Replies)
Discussion started by: Dan Rooney
4 Replies
Login or Register to Ask a Question