I've been trying to do some work with generating SQL commands with an interactive bash script and have a multiline string that I need to escape for use with MySQL.

Notes has already been defined as a multi-line string.

notes=$(echo "$notes" | php -r 'echo mysql_escape_string(fgets(STDIN));');

However, only one line is being returned. How can I get my multiline string properly escaped and returned?


Use pattern substitution:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.