<如何重定向&LT过程中运行bash命令; EOF [英] How to run bash command during redirect << EOF

查看:150
本文介绍了<如何重定向&LT过程中运行bash命令; EOF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道有一些方法重定向过程中运行bash命令,但我不知道它是怎么做的究竟

I know there's some way to run bash command during redirect, but I don't know how exactly it is done.

我想要做这样的事情:

#!/bin/bash
mysql -uUser -pPasswd << EOF
echo 'I wanna echo something by using echo which is run by bash'
use Mydb
some sql commands here
commit;
EOF

我做过的错误使用中的&LT;&LT; EOF,但没做,现在。

I had ever done that by mistake by using " in the "<< EOF" , but failed to make it now.

推荐答案

您可以使用的 的mysql 命令行客户端内的系统命令

You can use system command from within the mysql command line client:

#!/bin/bash
mysql -uUser -pPasswd << EOF
system echo 'I wanna echo something by using echo which is run by bash';
use Mydb
some sql commands here
commit;
EOF

这篇关于&LT;如何重定向&LT过程中运行bash命令; EOF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆