Useless Use of Cat

Debate on the 'Useless Use of Cat' (UUOC) in Unix shell pipelines, weighing readability and left-to-right data flow benefits against the inefficiency of spawning extra processes compared to input redirection or direct file arguments.

📉 Falling 0.3x DevOps & Infrastructure
3,255
Comments
20
Years Active
5
Top Authors
#2888
Topic ID

Activity Over Time

2007
1
2008
15
2009
20
2010
82
2011
90
2012
181
2013
175
2014
141
2015
208
2016
140
2017
228
2018
175
2019
196
2020
271
2021
249
2022
358
2023
262
2024
298
2025
149
2026
16

Keywords

e.g US LLM BEGIN OPTION OPERAND atop.log file.read domain.com EOH cat file command foo txt dd pipe unix output log

Sample Comments

HappyTypist Jul 10, 2016 View on HN

People like cat because it allows notating the command closer to how they think. How can I pipe while putting the file first?

mnbvkhgvmj Jun 18, 2019 View on HN

Surely using cat like this is more in line with the unix philosophy?

tzot May 3, 2021 View on HN

It's one more process to run, so `cat single_file | ` can be easily substituted with `<single_file `.

zaphar Mar 24, 2010 View on HN

How many people actually use shell redirection to copy and filter a file?

empath75 Jan 22, 2019 View on HN

People use cat to look at the file first, then hit up arrow, add a pipe, etc.

morsch Sep 6, 2012 View on HN

The ` < file` has to appear at/near the end of the line, right? Using cat has the advantage of being able to read the line from left to right along with the data flow. I often add more piped commands to the end of a line as I refine it, while the source data remains the same. (To be fair, sometimes the opposite is true.)

e12e Mar 12, 2023 View on HN

Hm. Why not re-use "tee"?https://www.man7.org/linux/man-pages/man1/tee.1.html

oneeyedpigeon Oct 21, 2024 View on HN

If only we could do `fileA> command >fileb` for the ultimate readability...

rawoke083600 Nov 13, 2018 View on HN

Cat is awesome :) There is also 'tac' (reverse of cat) installed on most systems

sunfish Aug 31, 2018 View on HN

"| cat" has this effect.