Find the answer to your Linux question:
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 ...
  1. #1
    Linux 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

  2. #2
    Just 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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...