SC2036 – ShellCheck Wiki

See this page on GitHub


If you wanted to assign the output of the pipeline, use a=$(b | c) .

Problematic code:

sum=find | wc -l

Correct code:

sum=$(find | wc -l)


The intention in this code was that sum would in some way get the value of the command find | wc -l.

However, | has precedence over the =, so the command is a two stage pipeline consisting of sum=find and wc -l.

sum=find is a plain string assignment. Since it happens by itself in an independent pipeline stage, it has no effect: it produces no output, and the variable disappears when the pipeline stage finishes. Because the assignment produces no output, wc -l will count 0 lines.

To instead actually assign a variable with the output of a command, command substitution $(..) can be used.


None. This warning is triggered whenever the first stage of a pipeline is a single assignment, which is never correct.

ShellCheck is a static analysis tool for shell scripts. This page is part of its documentation.