1

Find and replace text within multiple files

I found the above answer for finding and replacing regular strings, but it doesn't work with say replacing "none" with "Unitless" due to the syntax of the command.

Is there any way around this?

1 Answers1

3

The easiest solution is to change the outer quotes to single quotes:

sed 's/"none"/"Unitless"/g'

IMHO it's better to use single-quotes anyhow for literal strings - unless you need the double quote functionality specifically (for example, when using a shell variable in the pattern or replacement text).

Alternatively, escape the literal quotes: "s/\"none\"/\"Unitless\"/g"

dessert
  • 39,982
steeldriver
  • 136,215
  • 21
  • 243
  • 336
  • @ThomasKirven If this answer solved your issue, please take a moment and accept it by clicking on the check mark to the left. That will mark the question as answered and is the way thanks are expressed on the Stack Exchange sites. – dessert May 22 '19 at 07:09