Skip to content
Advertisement

Remove ” and n using sed

How to replace the below text using sed or in any other method.

"Revert "Release 1.0.0"nnThis reverts commit"

I need to replace the above to be like

"Revert Release 1.0.0 This reverts commit"

Advertisement

Answer

A or . needs to be escaped in regex pattern.

You may use this sed:

sed 's/"Revert \"Release 1.0.0\"\n\nThis reverts commit"/"Revert Release 1.0.0 This reverts commit"/' file
"Revert Release 1.0.0 This reverts commit"

You may consider this awk to remove " and n characters anywhere in the file:

awk '{gsub(/[[:blank:]]*(\["n])+/, " ")} 1' file
"Revert Release 1.0.0 This reverts commit"
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement