I have a large sql dump that has 1 insert statement per line. I want to be able to pipe this to xargs so that I can slow down the writes. Basically I want to execute a number of lines, sleep, then continue to execute and so forth.
I current have this:
cat file.sql | xargs -n50 -d "\n" sh -c '(echo "$@" | mysql db_name); sleep 10'
But the problem is that I believe somewhere in the file, there's a \n
that's causing sql to break. I'm using INSERT IGNORE
and this is resulting to missing rows.
I don't want to go through the file and fix the \n
. Is there a way to use line instead of \n
?
I've tried:
cat file.sql | xargs -L 50 sh -c '(echo "$@" | mysql db_name); sleep 10'
but I'm getting:
xargs: unmatched single quote; by default quotes are special to xargs unless you use the -0 option