Results 1 to 2 of 2
I'm planning to create a bash script wherein I need to fetch some data on my mysql. Here is my sample commands
mysql -uroot radius -e "select value1 from userupdate ...
- 05-19-2009 #1Linux Newbie
- Join Date
- Mar 2006
- Posts
- 101
get data on mysql using bash
I'm planning to create a bash script wherein I need to fetch some data on my mysql. Here is my sample commands
mysql -uroot radius -e "select value1 from userupdate where action = 'responseon' and update_date = '2009-05-19 08:26:04';"
The output of this command is:
+----------------------------------------------+
| value1 |
+----------------------------------------------+
| FOO T. LINUX <foolinux@linux.com> |
+----------------------------------------------+
Is there a chance that I can output only FOO T. LINUX <foolinux@linux.com> and all other character such as "-","+","|" will be removed?
TIA
- 05-19-2009 #2Just Joined!
- Join Date
- May 2009
- Posts
- 4
Go ahead and try some awking and do some grepping where neccessary.
Use the Field Separator to take out the -+. Then you can print specific fields of interest. Store the output of the query to a file then 'massage' it with Awk.
eg.
awk '{ FS="|"; print $2}' queryfile.log>toanotherfile.log
you can go a final step to awk some more to get the desired result.
Awk and grep are very useful admin tools.


Reply With Quote