LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-05-2004, 10:10 PM   #1
chynna_v
LQ Newbie
 
Registered: Sep 2004
Posts: 13

Rep: Reputation: 0
please look at my code


i have this code...

#!/bin/sh

DBS=`echo "select count(*) from out where bfr_id=60 and status=0" | mysql -uroot`
echo $DBS

and the output is
count(*) 5000

but i just wanted to get the value of the count in the actual database and not with the word "count(*)" in it...so i will be able to manipulate the value..im trying to write a script where it can echo the number of count in the database until the value is 0 then it will exit..how can i achieve this? any help will be appreciated.. thanks!
 
Old 09-05-2004, 10:26 PM   #2
zipster
LQ Newbie
 
Registered: Sep 2004
Posts: 2

Rep: Reputation: 0
Re: please look at my code

Quote:
Originally posted by chynna_v
i have this code...

#!/bin/sh

DBS=`echo "select count(*) from out where bfr_id=60 and status=0" | mysql -uroot`
echo $DBS

and the output is
count(*) 5000

but i just wanted to get the value of the count in the actual database and not with the word "count(*)" in it...so i will be able to manipulate the value..im trying to write a script where it can echo the number of count in the database until the value is 0 then it will exit..how can i achieve this? any help will be appreciated.. thanks!
Try changing the first line to be:
Code:
DBS=`echo "select count(*) from out where bfr_id=60 and status=0" | mysql -uroot | cut -d" " -f 2`
or something similar

God Bless

Zipster
 
Old 09-05-2004, 10:54 PM   #3
chynna_v
LQ Newbie
 
Registered: Sep 2004
Posts: 13

Original Poster
Rep: Reputation: 0
the output is still the same...
 
Old 09-06-2004, 12:48 PM   #4
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
Just use the -s option for mysql:

.... | mysql -s -uroot

Last edited by Hko; 09-06-2004 at 12:49 PM.
 
Old 09-06-2004, 08:22 PM   #5
chynna_v
LQ Newbie
 
Registered: Sep 2004
Posts: 13

Original Poster
Rep: Reputation: 0
Hi hiko! it worked! thanks a bunch!!! tried the whole day manipulating the code with the cut command...and just a simple "-s" did the thing! but i would also like to thank zipster because w/o him also i wouldn't be familiarze with the "cut"..very useful indeed
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
small syntax problem with C code (implemented in Code Composer Studio) illiniguy3043 Programming 6 01-07-2008 02:14 AM
User Preferences: Use HTML code instead of vB code? (vB code is overrated) stefanlasiewski LQ Suggestions & Feedback 5 07-26-2005 01:37 AM
Editing buttons (quote, code etc.) add the code to the end vharishankar LQ Suggestions & Feedback 2 09-13-2004 09:32 AM
Diffrerence between position independent code and Relocatable code? eshwar_ind Programming 7 05-11-2004 01:40 AM
Open Firmware code for booting OS from SATA : sample code available somewhere ? drsparikh Linux - Hardware 0 03-12-2004 11:16 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:12 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration