Created SC2037 (markdown)

koalaman
2016-10-11 10:29:26 -07:00
parent 6381290f54
commit 0ab68c1a33

20
SC2037.md Normal file

@@ -0,0 +1,20 @@
## To assign the output of a command, use var=$(cmd) .
### Problematic code:
```sh
var=grep -c pattern file
```
### Correct code:
```sh
var=$(grep -c pattern file)
```
### Rationale:
To assign the output of a command to a variable, use `$(command substitution)`. Just typing a command after the `=` sign does not work.
### Exceptions:
None.