More with cat
In the simplest case, cat is used to output lines of a file:
$ ls -l example -rw-r--r-- 1 ddailey faculty 102 Oct 2 14:55 example $ cat example Here is a simple text file consisting of two lines of text. Neither line is particularly interesting. $
If we have two (or more) files, we can use cat to output lines of both:
| $ cat example2 This file has three lines: one contains an artichoke another contains a pickle $ |
$ cat example Here is a simple text file consisting of two lines of text. Neither line is particularly interesting. $ |
$ cat example example2
Here is a simple text file consisting of two lines of text.
Neither line is particularly interesting.
This file has three lines:
one contains an artichoke
another contains a pickle
Using cat with two files and a redirect ">", we can con-cat-enate (meaning to append one string after another), whence the name "cat":
$ cat example example2>example3 $ ls -l example* -rw-r--r-- 1 ddailey faculty 102 Oct 2 14:55 example -rw-r--r-- 1 ddailey faculty 81 Oct 2 15:06 example2 -rw-r--r-- 1 ddailey faculty 183 Oct 2 15:09 example3
Observe that (102+81=183)! What might we expect of `wc example*`???