cat - concatenate files and print on the standard output


Usage

cat [OPTION] [FILE]...

Concatenate FILE(s), or standard input, to standard out-put.


Viewing a Sigle File

linux3[230]% ls
HelloWorld.c
linux3[231]% cat HelloWorld.c
/*
 * This program prints the message "Hello World!"
 * on the screen. The program is taken from the classic
 * C reference text "The C Programming Language" by
 * Brian Kernighan & Dennis Ritchie.
 */

#include <stdio.h>

int main () {

    printf("Hello World!\n");

    return 0;
}
linux3[232]%

Concatinating Multiple Files

linux3[253]% ls
colors1  colors2
linux3[254]% cat colors1
red rojo
green verde
blue azul
linux3[255]% cat colors2
white blanco
black negro
linux3[256]% cat colors1 colors2
red rojo
green verde
blue azul
white blanco
black negro
linux3[257]%

-n

Prepends all lines with its line number.

linux3[264]% cat -n HelloWorld.c
     1  /*
     2   * This program prints the message "Hello World!"
     3   * on the screen. The program is taken from the classic
     4   * C reference text "The C Programming Language" by
     5   * Brian Kernighan & Dennis Ritchie.
     6   */
     7
     8  #include <stdio.h>
     9
    10  int main () {
    11
    12     printf("Hello World!\n");
    13
    14     return 0;
    15  }
linux3[265]% man cat

Daniel J. Hood
Last modified: Thu Sep 30 13:32:13 EDT 2004