I need to replace the string ),(
with )\n,(
in a 10GB file. The \n in this case obviously stands for a newline.
I've tried so with this command:
sed -i '' '/),(/ s//),\n(/g' bigfile.sql
However, that didn't really work as expected. It did replace the string, but it didn't insert a newline, but simply a "n" (so it just neglected the backslash and escaped it).
Any other takes on this, or where's my mistake in the above command?
Best Answer
Try
$'...'
indicates that the string is a C-style string. This allows you to use the\\
and\n
escapes, among others.\n
, we have a\\
and then a\n
. This passes a literal backslash, and then a literal newline, tosed
. This allows it to recognize that the newline is a part of the pattern, instead of terminating it.The following also works: