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


© October 2003 Tony Lawrence

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

Inexpensive and informative Apple related e-books:

Take Control of Upgrading to El Capitan

Take Control of Apple Mail, Third Edition

Take Control of Parallels Desktop 12

Take Control of iCloud

Take Control of Numbers

More Articles by © Tony Lawrence

Printer Friendly Version

Have you tried Searching this site?

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

Printer Friendly Version

Why bother with subroutines when you can type fast? (Vaughn Rokosz)

Linux posts

Troubleshooting posts

This post tagged:



Unix/Linux Consultants

Skills Tests

Unix/Linux Book Reviews

My Unix/Linux Troubleshooting Book

This site runs on Linode