APLawrence.com -  Resources for Unix and Linux Systems, Bloggers and the self-employed



Conceptually equivalent to DOS "type", but the name is taken from its ability to con-CAT-enate multiple files to stdout. Few people bother to look at the man page, which is too bad, because it often has useful optional flags - the Linux and BSD versions are particularly feature rich.

"Useless use of cat award" is often sarcastically given to people who post things like:

cat file | more

because all that is needed is "more file". However, although perhaps wasteful (why would you care nowadays?), consider the situation where you have typed "cat file" and then realized that the display has run off your screen. If running bash, a simple up arrow and "| more" is easier than doing it "right". I confess to doing something similar fairly frequently. Every time I do it, I automatically think "useless use of cat..", but of course it really isn't.

People sometimes mistakenly invoke that "award" when someone does "cat *.c | grep something". That's NOT the same as "grep something *.c" and may be exactly what you need to do for the results you want.

"cat -e" is useful for showing where lines actually end - it adds a $ symbol to the end of each line. "cat -v" shows non-printing characters, "cat -t" shows tabs. "cat -s" can be useful in scripts as it is silent if what you asked it to cat doesn't exist.

"cat -u" is unbuffered cat, and doesn't buffer its output. This is seldom necessary, but if you are reading a FIFO it might help.

Got something to add? Send me email.

(OLDER)    <- More Stuff -> (NEWER)    (NEWEST)   

Printer Friendly Version

-> -> Unix 'cat' is moe versatile than you think

Increase ad revenue 50-250% with Ezoic

More Articles by

Find me on Google+

© Tony Lawrence

Kerio Samepage

Have you tried Searching this site?

Support Rates

This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more.

Contact us

Doing linear scans over an associative array is like trying to club someone to death with a loaded Uzi. (Larry Wall)

This post tagged: