forked from koalaman/shellcheck
-
Notifications
You must be signed in to change notification settings - Fork 0
SC2002
Vidar Holen edited this page Oct 4, 2015
·
8 revisions
cat file | tr ' ' _ | grep a_
cat file | ( while read i; do echo "${i%?}"; done )
< file tr ' ' _ | grep a_ # **simple commands only, won't work with compounds
( while read i; do echo "${i%?}"; done ) < file # postfix works for everything
cat
is a tool for con"cat"enating files. Reading a single file as input to a program is considered a Useless Use Of Cat (UUOC).
It's more efficient and less roundabout to simply use redirection. This is especially true for programs that can benefit from seekable input, like tail
or tar
.
Many tools also accept optional filenames, e.g. grep -q foo file
instead of cat file | grep -q foo
.
None.