• Home
  • LLMs
  • Docker
  • Kubernetes
  • Java
  • All
  • About
Linux-Ubuntu | cat -- concatenate and print files
  1. Notes
  2. Examples
  3. Command Help (man cat)

  1. Notes
    cat file ...

    The cat command takes a list of file names for its arguments.
    It outputs the contents of those files directly to the standard output, which, by default, is directed to the screen.
  2. Examples
    • Write the content of a file:
      $ cat file1
      Hello
      
      file1

      You can use the option -n to print the line number:
      $ cat -n file1
           1    Hello
           2
           3    file1

    • Write the content of multiple files:
      $ cat file1 file2 file3

    • Write the content of multiple files one by one (enter EOF character ('^D') for each file):
      $ cat file1 - file2 - file3
  3. Command Help (man cat)
    The following options can be used:
    -n
    |Number the output lines, starting at 1.
    
    -b
    |Number the non-blank output lines, starting at 1.
    
    -v
    |Display non-printing characters so they are visible.
    |Control characters print as "^X" for control-X; the delete character (octal 0177) prints as "^?".
    |Non-ASCII characters (with the high bit set) are printed as "M-" (for meta) followed by the character for the low 7 bits.
© 2025  mtitek