1
0
mirror of https://github.com/koalaman/shellcheck.git synced 2025-03-12 12:35:25 -07:00

Updated SC2216 (markdown)

koalaman 2017-07-03 16:02:37 -07:00
parent 3036bd8f85
commit a436bef6e9

@ -1,20 +1,24 @@
## Piping to 'echo', a command that doesn't read stdin. Wrong command or missing xargs?
## Piping to 'rm', a command that doesn't read stdin. Wrong command or missing xargs?
### Problematic code:
```sh
find . -type f | echo "Results: "
ls | echo # Want to print result
cat files | rm # Want to delete items from a file
find . -type f | xargs cp dir # Want to process 'find' output
```
### Correct code:
```sh
find . -type f -print0 | xargs -0 echo "Results: "
ls
cat files | while IFS= read -r file; do rm -- "$file"; done
find . -type f -exec cp {} dir \;
```
### Rationale:
You are redirecting to one of several commands that don't read from stdin.
You are piping to one of several commands that don't read from stdin.
This may happen when: