mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-10-03 19:29:44 +08:00
wrong exit code when matches are found in grep
@@ -16,7 +16,7 @@ grep -c foo
|
|||||||
|
|
||||||
This is purely a stylistic issue. `grep` can count lines without piping to `wc`.
|
This is purely a stylistic issue. `grep` can count lines without piping to `wc`.
|
||||||
|
|
||||||
Note that in many cases, this number is only used to see whether there are matches (i.e. `> 0`). In these cases, it's better and more efficient to use `grep -q` and check its exit status:
|
Note that in many cases, this number is only used to see whether there are matches (i.e. `== 0`). In these cases, it's better and more efficient to use `grep -q` and check its exit status:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
if grep -q pattern file
|
if grep -q pattern file
|
||||||
|
Reference in New Issue
Block a user