If you want to replace COLNAME|
with COLNAME"|"
in Windows, using the GNU sed
, you can use
"C:Program Files (x86)GnuWin32insed.exe" "s/COLNAME|/COLNAME"^""|"^""/g"
Here, COLNAME|
matches COLNAME|
and COLNAME"^""|"^""
forms the literal COLNAME"|"
replacement since COLNAME"
ends the quoted string, ^"
appends a literal "
char to the sed command, "|"
appends a |
char to the sed command and then ^"
appends another literal "
to the sed command, and the next "
starts the finishing part. The g
flag makes it match and replace all occurrences.
If you want to replace COLNAME"|"
with COLNAME
in Windows, using the GNU sed
, you can do that with
"C:Program Files (x86)GnuWin32insed.exe" "s/COLNAME"^""|"^""/COLNAME/g" FILENAME
"C:Program Files (x86)GnuWin32insed.exe" "s/COLNAMEx22|x22/COLNAME/g" FILENAME
"C:Program Files (x86)GnuWin32insed.exe" "s/COLNAMEd34|d34/COLNAME/g" FILENAME
Mind that you need to enclose the substitution command with double quotes and to match a double quote, you can't simply use a "
or a "
, you can match it with an escaped ^"
, or with x22
, a hex reprentation of the char, or d34
.
Note that in "s/COLNAME"^""|"^""/COLNAME/g"
, the sed command is built in the following way:
"s/COLNAME"
sets the beginning
^"
appends a literal "
char to the sed command
"|"
- adds |
pipe char
^"
- adds another "
"/COLNAME/g"
- finishes off the sed command with the replacement and the global modifier/flag.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…