mirror of
https://github.com/tldr-pages/tldr.git
synced 2025-08-10 07:15:43 +02:00
various fixes and tweaks to sed
- don't use g in all examples - fix option for extended regex (-E is in grep :)) - spell out the -i option and remove a stray `''` from that command - use the term "expressions" in the example using -e
This commit is contained in:
parent
5d3143bbf5
commit
0348a644de
1 changed files with 7 additions and 7 deletions
|
@ -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}}`
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue