Docker

Docker

Made by DeepSource

Useless cat detected DOK-SC2002

Anti-pattern
Major

cat is a tool for concatenating 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.

Bad Practice

cat file | tr ' ' _ | nl
cat file | while IFS= read -r i; do echo "${i%?}"; done

Recommended

< file tr ' ' _ | nl
while IFS= read -r i; do echo "${i%?}"; done < file