I am trying to execute multiple sed operations on the find -exec operation. My code looks like this:
find . -name '*.html.haml' -exec sed -i '' 's/restaurant_id/company_id/g' && sed -i '' 's/restaurants/companies/g' && sed -i '' 's/restaurant/company/g' && sed -i '' 's/Restaurants/Companies/g' && sed -i '' 's/Restaurant/Company/g' "{}" \;
This seems not to work. How could I do that?
Error:
find: -exec: no terminating ";" or "+"
As others have said, the problem is that the
&&is interpereted to execute the sed command after thefindcommand is finished, instead of passing one string of commands to be executed on each file.The easiest way to achieve your desired result is to combine this all into one
sedcommand with semicolons. Like so: