In some situations I would like to store complete commands and output from terminal sessions in a MySQL database.

Ideally I would just copy the command and output from the terminal to my clipboard then just paste into a simple bash script that would update the relevant field.

I have experimented with using the read function in bash, see below. However when pasting multiple lines into the read it does not parse the line breaks correctly.


read -e -p "name: " name
read -e -p "output: " ouput

mysql -u example@localhost << EOF
use database;
insert into table (name, output) values('$title', '$output');


I know this is not elegant, but would really useful reference for me in the future.

Perhaps somebody could shed some light on a better way to get this done...

Thanks in advance,


To paste multilines in a variable, I would do :


echo -en 'Paste your multiline content and ^D to submit >>> '
echo "$content"

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.