Multiple times we get requests in projects to generate reports from database. Below command will be helpful in exporting the MySQL query results directly into CSV (comma separated values) file mysql -h {hostname} -u {username} -p {database_name} -B -e “SELECT code AS ‘Coupon Codes’ FROM salesrule_coupon WHERE rule_id=112” | sed “s/\t/,/g” > /tmp/coupon_code_$(date +%F).csv Above […]