diff --git a/SC2037.md b/SC2037.md new file mode 100644 index 0000000..bd03726 --- /dev/null +++ b/SC2037.md @@ -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. \ No newline at end of file