Created
October 28, 2016 04:48
-
-
Save petrabarus/fd83ebab7126179045650e31c553db5e to your computer and use it in GitHub Desktop.
Group lines from file to be executed in MySQL WHERE .. IN ...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
seq 12 | pr -7ats, | xargs -I X echo "SELECT * FROM Table WHERE id IN (X)" | |
#output | |
#SELECT * FROM Table WHERE id IN (1,2,3,4,5,6,7) | |
#SELECT * FROM Table WHERE id IN (8,9,10,11,12) | |
seq 12 | pr -7ats | xargs -I X mysql database -e "DELETE FROM Table WHERE id IN (X)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment