You're replying to a comment by Xezlec.

Xezlec Permalink
July 23, 2009, 20:48

There certainly can be good reasons not to uselessly use cat, and getting into the habit of doing so can be a bad thing, especially if your code is likely to be used as a bible by relatively uninformed users (as yours is).

I work at a place where relatively uninformed users routinely set up large, super-high-bandwidth pipes on compute clusters using cat, in which case cat may waste significant CPU (what's the block size that it's reading from disk, I wonder?). Furthermore, cat gives you a one-way stream as output, so downstream apps don't have the ability to get information about the original file (such as size) or to seek back and forth. In general, streams < files.

The end result is that my carefully written C code with all its carefully optimized seeking behavior ends up wasting hours burning through hundreds of terabytes of unneeded data just because it doesn't have a seekable input descriptor, and then the users complain that their code is slow and after debugging I find that they're doing this junk and remind them (again!) not to do this, and then two months later they copy some code off of yet another blog like this and yet again don't notice that the cat is not necessary and yet again complain that their code is slow...... etc.

So yeah, I guess I feel like if I wrote a blog claiming to be anything resembling a how-to, I'd try to write pretty good code, just to be nice and not give people bad ideas. But it's your blog of course, and your call.

Reply To This Comment

(why do I need your e-mail?)

(Your twitter handle, if you have one.)

Type the word "disk_132": (just to make sure you're a human)

Please preview the comment before submitting to make sure it's OK.