Concatenate Files to stdout


cat file1 file2

cat is short for concatenate, which means "to join together." The original purpose of cat is to take two or more files and concatenate them into one file (the fact that you can use the cat command on just one file and print it on the screen is a bonus). For instance, let's say you have a short poem by A. E. Housman and one by Francis Quarles, and you want to view them at the same time.

$ cat housman_-_rue.txt quarles_-_the_world.txt WITH rue my heart is laden   For golden friends I had, For many a rose-lipt maiden   And many a lightfoot lad. By brooks too broad for leaping   The lightfoot boys are laid; The rose-lipt girls are sleeping   In fields where roses fade. The world's an Inn; and I her guest. I eat; I drink; I take my rest. My hostess, nature, does deny me Nothing, wherewith she can supply me; Where, having stayed a while, I pay Her lavish bills, and go my way. 


Notice that cat doesn't separate the two files with a horizontal rule, a dash, or so forth. Instead, cat mashes the two files together and spits them out. If you want more of a separationhaving the last line of "With rue my heart is laden" jammed up right next to the first line of "On the world" makes them hard to read, for instancemake sure there's a blank line at the end of each file you're going to concatenate together.



Linux Phrasebook
Linux Phrasebook
ISBN: 0672328380
EAN: 2147483647
Year: 2007
Pages: 288

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net