0

In multiple files, there are format("d-m-Y H:i") at multiple places. There I want to replace "d-m-Y H:i" with DATE_FORMAT.'H:i' so the final string of the file should be format(DATE_FORMAT.'H:i') . Here, DATE_FORMAT is a global constant.

Tried with the following code

find . -type f -name '*.php' -exec sed -i "" s/\"d-m-Y H:i\"/DATE_FORMAT.'H:i'/g {} +

but getting error

sed: 1: "s/"d-m-Y": unterminated substitute pattern

Tomerikoo
  • 15,737
  • 15
  • 35
  • 52
Amitesh Bharti
  • 10,566
  • 5
  • 53
  • 51
  • 1
    you need to quote the entire substitute command to avoid shell interpreting characters like space (for example `d-m-Y H:i` in your code). Using `"s/\"d-m-Y H:i\"/DATE_FORMAT.'H:i'/g"` should work I think – Sundeep Jan 12 '22 at 08:13

0 Answers0