0

My goal is to replace str-a with str-b in all the files in the folder src.

I tried:

find src -type f -exec sed -i "" 's/a-table/chi-table/g' {} +

As a result, I get this error:

sed: RE error: illegal byte sequence

  • Would suggest removing `""` and quoting the filename, e.g. `'{}'`. – David C. Rankin Mar 17 '20 at 19:36
  • @DavidC.Rankin, ...whether `sed -i ""` is correct depends on which platform one is on; on some BSDs (including MacOS) the suffix argument after `-i` is mandatory. And an unquoted `{}` is valid in bash, though it may be a problem in some other shells. – Charles Duffy Mar 17 '20 at 19:38
  • Good advice, thank you @CharlesDuffy. I'm always a bit cloudy on mac use and quote out of habit to ensure no issues regardless of OS... – David C. Rankin Mar 17 '20 at 19:39
  • •nod*. What's relevant here is that it's `find` honoring the `{}` substitution, which it does *after* the shell has invoked it; so one doesn't need to worry about how the filename would be parsed unquoted, but only about how the currently-active shell will treat the string `{}` unquoted. – Charles Duffy Mar 17 '20 at 19:41

0 Answers0