![Linux sed 명령을 bsd로 변환하는 방법](https://linux55.com/image/11716/Linux%20sed%20%EB%AA%85%EB%A0%B9%EC%9D%84%20bsd%EB%A1%9C%20%EB%B3%80%ED%99%98%ED%95%98%EB%8A%94%20%EB%B0%A9%EB%B2%95.png)
macOS 터미널에서 이 기능을 어떻게 구현하나요?
sed -i 's/config.action_mailer.default_url_options =.*$/config.action_mailer.default_url_options = {:host => "localhost:3000"}/g' config/environments/development.rb
sed: 1: "config/environments/dev ...": command c expects \ followed by text
답변1
문제는 그 다음 매개변수가 -i
소스 파일의 백업 복사본에 추가하기 위한 문자열로 사용된다는 것입니다. 올바른 구문은 다음과 같습니다.
sed -i '.BAK' 'command' file
.BAK
다음 인수가 누락되어 config/…
실행될 명령으로 남고 sed는 해당 c
명령( 의 첫 문자 command
)을 실행하려고 시도하고 실패합니다.
그럼 이건 정확한 사본이군요sed -i(제자리에서 편집)를 사용하여 이식성을 달성하는 방법은 무엇입니까?