Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Batch - String replacement with special characters

I would like to replace a string in a file using a batch file.

The string is:

),(

And I want to replace it by:

),
(

I found several posts, like this one : "how-to-replace-substrings-in-windows-batch-file" but the example uses a dummy string with no special characters.

Thank you !

EDIT

Context: I use mysqldump to extract a database and I would like every line of the insert command to be on a new line for more visibility.

I don't want to use --extended-insert=false because it slows down reinsertion of the backup.

EDIT2

Example:

INSERT INTO `dummytable` (`dummycolumn`) VALUES (1),(2),(3);

I want it to be:

INSERT INTO `dummytable` (`dummycolumn`) VALUES (1),
(2),
(3);
like image 850
Sara Avatar asked May 25 '26 09:05

Sara


1 Answers

Take a look at replacer.bat

call replacer.bat "e?C:\content.txt" "\u0022),(\u0022" "\u0022),\u000a(\u0022"

Edit without the quotes:

call replacer.bat "e?C:\content.txt" "),(" "),\u000a("

windows style

call replacer.bat "e?C:\content.txt" "),(" "),\u000D\u000a("

you can check also FindRepl and JRepl which are more sophisticated tools

like image 87
npocmaka Avatar answered May 30 '26 15:05

npocmaka



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!