LinuxQuestions.org
Review your favorite Linux distribution.
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-06-2010, 09:39 AM   #1
felipefls
LQ Newbie
 
Registered: Jan 2010
Location: Brazil
Distribution: Fedora, Ubuntu
Posts: 5

Rep: Reputation: 0
Help with Shell Script


I did a select on my db and now I need that this if consult return true for me salve the columns information in file.

How I do this in Shell?!
 
Old 09-06-2010, 04:04 PM   #2
slakmagik
Senior Member
 
Registered: Feb 2003
Distribution: Slackware
Posts: 4,113

Rep: Reputation: Disabled
We'll probably need a lot more, clearer information. Maybe something like

Code:
if my_var=$(my_db_command 2>/dev/null); then
    echo "$my_var" > my_file
fi
but I'm not sure if that's what you're asking.
 
1 members found this post helpful.
Old 09-06-2010, 07:43 PM   #3
AnanthaP
Member
 
Registered: Jul 2004
Location: Chennai, India
Posts: 952

Rep: Reputation: 217Reputation: 217Reputation: 217
If you can see the select results in your shell by running the sql at the shell prompt, then you should be able to redirect the output to a file.
 
Old 09-17-2010, 08:41 AM   #4
felipefls
LQ Newbie
 
Registered: Jan 2010
Location: Brazil
Distribution: Fedora, Ubuntu
Posts: 5

Original Poster
Rep: Reputation: 0
Hi guys, today I return with my tests and I see that I was wrong way.
Is better to copy the select to file. Well, I try but my code copy everything, since "select....." until "1 row in set....".
How I do to copy only result of select?

I hope you can understand me.

Bellow my code:

mysql -vv -u root -pcolorado -e "select email from birt\
where date_format(dn,'%dd%') = date_format(Current_date,'%dd%')\
and date_format(dn,'%mm%') = date_format(Current_date,'%mm%');"\
birthday >> teste


thank's.

Att.
Felipe Lima
 
  


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
Executing a Shell script with 654 permissions inside another shell script. changusee2k Linux - Newbie 2 06-07-2011 07:58 PM
pass variable from one shell script into another shell script xskycamefalling Programming 9 10-03-2009 01:45 AM
help with execute mulitple shell script within shell script ufmale Programming 6 09-13-2008 12:21 AM
shell script problem, want to use shell script auto update IP~! singying304 Programming 4 11-29-2005 05:32 PM

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

All times are GMT -5. The time now is 03:03 PM.

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