1
0
Fork 0
mirror of https://github.com/tldr-pages/tldr.git synced 2025-08-03 21:35:40 +02:00

sed: swap extended regex & line pattern examples

This commit is contained in:
Waldir Pimenta 2016-04-21 19:13:01 +01:00
parent 1c76b8ea7b
commit 685b6ea8bd
2 changed files with 8 additions and 8 deletions

View file

@ -6,17 +6,17 @@
`sed 's/{{find}}/{{replace}}/' {{filename}}`
- Replace only on lines matching the line pattern:
- Replace all occurrences of an extended regular expression in a file:
`sed '/{{line_pattern}}/s/{{find}}/{{replace}}/'`
`sed -r 's/{{regex}}/{{replace}}/g' {{filename}}`
- Replace all occurrences of a string in a file, overwriting the file (i.e. in-place):
`sed -i 's/{{find}}/{{replace}}/g' {{filename}}`
- Replace all occurrences of an extended regular expression in a file:
- Replace only on lines matching the line pattern:
`sed -r 's/{{regex}}/{{replace}}/g' {{filename}}`
`sed '/{{line_pattern}}/s/{{find}}/{{replace}}/'`
- Apply multiple find-replace expressions to a file:

View file

@ -6,17 +6,17 @@
`sed 's/{{find}}/{{replace}}/' {{filename}}`
- Replace only on lines matching the line pattern:
- Replace all occurrences of an extended regular expression in a file:
`sed '/{{line_pattern}}/s/{{find}}/{{replace}}/'`
`sed -E 's/{{regex}}/{{replace}}/g' {{filename}}`
- Replace all occurrences of a string in a file, overwriting the file (i.e. in-place):
`sed -i '' 's/{{find}}/{{replace}}/g' {{filename}}`
- Replace all occurrences of an extended regular expression in a file:
- Replace only on lines matching the line pattern:
`sed -E 's/{{regex}}/{{replace}}/g' {{filename}}`
`sed '/{{line_pattern}}/s/{{find}}/{{replace}}/'`
- Apply multiple find-replace expressions to a file: