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

cat

2003/10/16

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?

Unix/Linux/Mac OS X support by phone, email or on-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





An atheist is just somebody who feels about Yahweh the way any decent Christian feels about Thor or Baal or the golden calf. As has been said before, we are all atheists about most of the gods that humanity has ever believed in. Some of us just go one god further. (Richard Dawkins)

Getting information off the Internet is like taking a drink from a fire hydrant. (Mitchell Kapor)







This post tagged: