fix small typo

Matthias Morin
2021-02-13 22:16:30 +01:00
parent 01ffd6566c
commit e7c9b570ff

@@ -3,13 +3,13 @@
### 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:
@@ -21,7 +21,7 @@ Let's assume somewhere earlier in your code you have put data into a variable (E
Occasionally a more complex sed substitution is required. For example, getting the last character of a string. Occasionally a more complex sed substitution is required. For example, getting the last character of a string.
```sh ```sh
string="stirng" ; echo "$string" | sed -e "s/^.*\(.\)$/\1/" string="string" ; 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 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.