this post was submitted on 03 Aug 2026
431 points (98.2% liked)
Programmer Humor
32702 readers
1111 users here now
Welcome to Programmer Humor!
This is a place where you can post jokes, memes, humor, etc. related to programming!
For sharing awful code theres also Programming Horror.
Rules
- Keep content in english
- No advertisements
- Posts must be related to programming or programmer topics
founded 3 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
I'm scared to run that.
Is that like some kind of fork bomb?
Or is it just a tubular cat?
it won't... do anything
it'll wait for you to type ten lines (the default for
headwithout arguments), buffer them (bctailmust buffer its input), then spit them back at you, and exitheadtakes the first N lines of its input (if-n <number>is not specified, the default is 10 lines, and default reading from stdin, which in this case is your terminal) and prints them to its stdout (which thanks to the pipe, goes directly tocat's stdin), then signals end-of-file.cataccepts any number of filenames and conCATenates them (hence the name), writing their contents one after the other to stdout. with only one file as argument (the most common case in practice) it will simply write that file's contents to stdout. with no arguments (as in this case) it will simply copy everything from its stdin (in this casehead's stdout) to its stdout (in this casetail's stdin). thecatcommand could be completely omitted from this invocation (leaving simplyhead | tail) and it would work exactly the same.tailreads its entire input (likehead, it defaults to reading from stdin unless a filename is specified) and buffers it, then, when the end of the file is reached, it prints the last N lines is read (again defaulting to 10 unless-n <number>is specified) to stdout (in this case your terminal).put all together,
headwill wait for you to type a line, then will pass it on tocat, which will then immediately pass it on totail, which will add it to a buffer and wait for another line. rinse and repeat until you have typed 10 lines, and thenheadwill exit and the pipe between it andcatwill close.cat, noticing the closed pipe, will exit in turn, causing the pipe between it andtailto close.tail, seeing an end of file signal on its input pipe, will cough up the last 10 lines in its buffer and then exit. sinceheadonly sent it 10 lines, this is the entirety of its input. so it will spit back everything you typed.If you press Ctrl+D to send
headan end-of-file signal before you have typed 10 lines,headwill exit immediately, causingcatto exit, causingtailto output everything it had in its buffer so far.Put suspicious cats into sandboxes until it's proven that they are crewmates.