sed -i "" "s/<search_expression>/<replace_expression>/g" "<file_path>"
Code language: Bash (bash)
On Mac:
sed -i "" "s/<search_expression>/<replace_expression>/g" "<file_path>"
Code language: Bash (bash)
It’s different because MacOS requests one more parameter for backing up the original file. If you enter an extension to the empty parameter below, it backs up the original with that suffix:
sed -i ".bak" "s/<search_expression>/<replace_expression>/g" "<file_path>"
Code language: Bash (bash)
This replaces the file and keeps the original in <file_path>.bak file.
Leave a Reply