sed: fix faulty example and add remove line from file osx (#4781)

This commit is contained in:
Stefan Wessels Beljaars
2020-10-24 16:10:25 +02:00
committed by GitHub
parent ca7388b08f
commit b9e393f602

View File

@@ -10,9 +10,9 @@
`sed -E 's/{{regex}}/{{replace}}/g' {{filename}}` `sed -E 's/{{regex}}/{{replace}}/g' {{filename}}`
- Replace all occurrences of a string in a file, overwriting the file (i.e. in-place): - Replace all occurrences of a string [i]n a file, overwriting the file (i.e. in-place):
`sed --in-place='' 's/{{find}}/{{replace}}/g' {{filename}}` `sed -i '' 's/{{find}}/{{replace}}/g' {{filename}}`
- Replace only on lines matching the line pattern: - Replace only on lines matching the line pattern:
@@ -29,3 +29,7 @@
- Replace separator / by any other character not used in the find or replace patterns, e.g., #: - Replace separator / by any other character not used in the find or replace patterns, e.g., #:
`sed 's#{{find}}#{{replace}}#' {{filename}}` `sed 's#{{find}}#{{replace}}#' {{filename}}`
- [d]elete the line at the specific line number [i]n a file, overwriting the file:
`sed -i '' '{{line_number}}d' {{filename}}`