Fix typos in docs and grammar updates

Daniel Wright
2023-02-27 12:04:55 +10:00
parent bffb3a8c25
commit 4e8b9f19c7

@@ -3,18 +3,18 @@
### Problematic code: ### Problematic code:
```sh ```sh
string="stirng" ; echo "$string" | sed -e "s/ir/ri/" string="string" ; echo "$string" | sed -e "s/ir/ri/"
``` ```
### Correct code: ### Correct code:
```sh ```sh
string="stirng" ; echo "${string//ir/ri}" string="string" ; echo "${string//ir/ri}"
``` ```
### Rationale: ### Rationale:
Let's assume somewhere earlier in your code you have put data into a variable (Ex: $string). Now you want to do a search and replace inside the contents of $string and echo the contents out. You could pass this to sed as done in the example above, but for simple substitutions, parameter expansion can do it with less overhead. Let's assume somewhere earlier in your code, you have put data into a variable (Ex: $string). Now you want to search and replace inside the contents of $string and echo the contents out. You could pass this to sed as done in the example above, but for simple substitutions, a parameter expansion can do it with less overhead.
### Exceptions ### Exceptions
@@ -24,7 +24,7 @@ Occasionally a more complex sed substitution is required. For example, getting t
string="stirng" ; echo "$string" | sed -e "s/^.*\(.\)$/\1/" string="stirng" ; echo "$string" | sed -e "s/^.*\(.\)$/\1/"
``` ```
This is a bit simple for the example and there are alternative ways of doing this in the shell, but this SC2001 flags on several of my crazy complex sed commands which are beyond the scope of this example. Utilizing some of the more complex capabilities of sed is required occasionally and it is safe to ignore SC2001. This is a bit simple for the example, and there are alternative ways of doing this in the shell, but this SC2001 flags on several of my crazy complex sed commands beyond this example's scope. Utilizing some of the more complex capabilities of sed is required occasionally, and it is safe to ignore SC2001.
### Related resources: ### Related resources: