I am writing a shell script in which I want to redirect the output of a mysql query result into a file. I have experimented with a sample help I got from the web but did not help :
#!/bin/sh
mysql --user=root --password=ibj -h localhost <<!!
USE mydb;
SELECT * FROM shino WHERE dbflag=0;
quit
!!
Actually , I have never used the syntax "<< ......... quit !! " before and I do not have documentation to read about it.
So when I execute the script as it is , it dispalys the result of the query on the screen. Now when I changed the select statement to
"SELECT * FROM shino WHERE dbflag =0;">>/tmp/$$.tempfile
it gave me a syntax error ,likewise with
mysql -e "SELECT * FROM shino" >>/tmp/$$.tempfile
Can someone give me the correct syntax to be able to put the result of a mysql query into a file.
Thanks ,
Ibro