diff --git a/pages/common/sed.md b/pages/common/sed.md index 87c4d0b4fa..6e07a388d5 100644 --- a/pages/common/sed.md +++ b/pages/common/sed.md @@ -2,21 +2,21 @@ > Run replacements based on regular expressions -- replace all occurrences of a string in a file, and print the result +- replace the first occurrence of a string in a file, and print the result -`sed 's/{{find}}/{{replace}}/g' {{filename}}` +`sed 's/{{find}}/{{replace}}/' {{filename}}` -- replace all occurrences of a string in a file, and overwrite the file +- replace all occurrences of a string in a file, overwriting the file contents -`sed -i '' 's/{{find}}/{{replace}}/g' {{filename}}` +`sed --in-place 's/{{find}}/{{replace}}/g' {{filename}}` - replace all occurrences of an extended regular expression in a file -`sed -E 's/{{regex}}/{{replace}}/g' {{filename}}` +`sed -r 's/{{regex}}/{{replace}}/g' {{filename}}` -- replace all occurrences of multiple strings in a file +- apply multiple find-replace expressions to a file -`sed -e 's/{{find}}/{{replace}}/g' -e 's/{{find}}/{{replace}}/g' {{filename}}` +`sed -e 's/{{find}}/{{replace}}/' -e 's/{{find}}/{{replace}}/' {{filename}}`