Add advice for multiple files - https://github.com/koalaman/shellcheck/issues/1920

Michael Diamond
2020-04-23 11:52:23 -07:00
parent 21612f1733
commit df4551468a

@@ -12,6 +12,20 @@ grep foo | wc -l
grep -c foo
```
#### For multiple files
Instead of:
```sh
grep foo *.log | wc -l
```
Pipe all the file contents into `grep` (passing the files directly to `grep` causes `-c` to print each file's count separately, rather than the total):
```sh
cat *.log | grep foo -c
```
### Rationale:
This is purely a stylistic issue. `grep` can count lines without piping to `wc`.