Skip to content

useless-cat

Shellstyleno fixdefault: offshell/shellcheck

Reports a pipeline that starts with cat file.

cmd < file does the same without a process and a pipe, and gives the command a file it can seek in.

To fix, write cmd < file, or pass the file as an argument.

Reported
cat in.txt | grep x
cat -n in.txt | grep x
cat a b | grep x
grep x in.txt
...
shell:
lint:
rules:
useless-cat: warn # off (default), warn, error

Enabled by the presets: shell/shellcheck.

Suppress one line with sudsy-disable-next-line useless-cat in a comment of the file’s language.

The same check in other tools; Sudsy reports what each upstream rule reports.

Tool Rule Match
shellcheck SC2002 full