I came across a lot of answers, including theses:
- sed on OSX insert at a certain line
- https://stackoverflow.com/questions/14846304/sed-command-error-on-macos-x
- https://stackoverflow.com/questions/4247068/sed-command-failing-on-mac-but-works-on-linux
- https://stackoverflow.com/questions/16266281/how-to-add-text-to-the-beginning-of-all-files-in-a-folder
And I can't find a way to do what I want to do. I need to insert #encoding:utf-8
at the beginning of every .html.erb
file of my directory (recursively). I tried using this command
find . -iname "*.erb" -type f -exec sed -ie "1i \#encoding:utf-8" {} \;
But it throws this error:
sed: 1: "1i #encoding:utf-8": extra characters after \ at the end of i command