I'm using MySQL 5.0.27 on redhat-linux, Fedora Core 4.
I am attempting to write a Bash Shell script that extracts data from a MySQL database and puts it in a text file (that I can use for other scripts).
I am able to get the data output, but I don't know how to correctly format it. I need the data in rows (one item per row) and without column headers or the dashes and lines . Code below:
#Read the IP addresses from the MySQL database
DATA="$($MYSQL -u $MUSER -h $MHOST -p$MPASS -t networkscan -e 'select ipaddress from data WHERE datetime<NOW();')"
echo $DATA > File
The resulting file looks like this:
+--------------+ | ipaddress | +--------------+ | 192.168.1.56 | | 192.168.1.7 | | 192.168.1.3 | | 192.168.1.74 | | 192.168.1.12 | | 192.168.1.56 | +--------------+
I need it to look like this:
I've read that there are various parameters for formatting, such as -E that creates a separate line for each entry, but I must not be adding that in the correct place, because I can't get it to work. Any help is appreciated.