Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pipe SED output to mysql

Tags:

mysql

sed

I'm an trying to pipe output data directly from sed into mysql by doing something like:

sed "s/url\/uct\/video/url\/uct\/video/g" 2019-11-25T0330-main.sql.gz | mysql opencast

Is this possible? I keep running out of space and therefore piping it straight into mysql would be ideal (instead of running sed independently).

like image 437
Chognificent Avatar asked Oct 14 '25 22:10

Chognificent


1 Answers

You need

gunzip main.sql.gz | sed 's@url/uct/video@url/uct/video@g' | mysql opencast

Note if you use a different char besides / for seds s/str/rep/ you can avoid having to escape / chars that are part of the sub/repl patterns. For some OS's (besided Linux) users, you may need to escape the first use of the alternate delimit character, like sed '\@sub@repl@

And if you are using the -i option for sed, it doesn't make sense in the context of reading input from a pipe ;-)

IHTH

like image 65
shellter Avatar answered Oct 17 '25 12:10

shellter



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!