Pass both run-check stdout and stderr to grep and select lines containing FAIL.
Use POSIX syntax.
Which command sequence is appropriate?
Redirect stderr to stdout on the left command, then pipe the combined stream to grep.
Detailed explanation
run-check | grep FAILIncorrect. Only stdout enters the pipe; stderr stays on the terminal.
run-check 2>&1 | grep FAILCorrect. 2>&1 merges both streams before the pipe sends them to grep.
run-check 2> grep FAILIncorrect. This redirects stderr to a file named grep rather than piping it.
run-check | grep FAIL 2>&1Incorrect. It redirects grep's own stderr and does not pipe run-check stderr.
Try it yourself
An example you can run in a temporary verification environment.
sh -c 'echo OK; echo FAIL-error >&2' 2>&1 | grep FAILExpected result
FAIL-errorKey points
- A pipe normally carries stdout only
- 2>&1 merges stderr
- Merge on the left command
Notes
- Environment: POSIX shell / grep / 生成出力
- Use temporary files and harmless commands for stream experiments.
- Shell redirection syntax and xargs behavior should be checked on the target shell implementation.
Foundation review
Place the operation
A normal pipeline carries standard output only; an explicit merge is needed for diagnostics too.
Check the side effect
Emit one line on each descriptor and confirm both reach the filter.