June 8, 2012
One of the on-going themes here at Programming Praxis involves the re-implementation of the text utilities from Unix V7. Today we look at the
cat – catenate and print
cat [ -u ] file …
Cat reads each file in sequence and writes it on the standard output. Thus
prints the file and
cat file1 file2 >file3
concatenates the first two files and places the result on the third.
If no file is given, or if the argument ‘-‘ is encountered, cat reads from the standard input. Output is buffered in 512-byte blocks unless the standard output is a terminal or the -u option is present.
Beware of ‘cat a b >a’ and ‘cat a b >b’, which destroy input files before reading them.
Pages: 1 2