HiveBrain v1.2.0
Get Started
← Back to all entries
snippetbashTip

cat — Print and concatenate files. More information: <https://www.gnu.org/software/coreutils/manual/html_n

Submitted by: @import:tldr-pages··
0
Viewed 0 times
commandfilescatandconcatenatecliprintmore
linux

Problem

How to use the cat command: Print and concatenate files. More information: <https://www.gnu.org/software/coreutils/manual/html_node/cat-invocation.html>.

Solution

cat — Print and concatenate files. More information: <https://www.gnu.org/software/coreutils/manual/html_node/cat-invocation.html>.

Print the contents of a file to stdout:
cat {{path/to/file}}


Concatenate several files into an output file:
cat {{path/to/file1 path/to/file2 ...}} > {{path/to/output_file}}


Append several files to an output file:
cat {{path/to/file1 path/to/file2 ...}} >> {{path/to/output_file}}


Write to a file interactively:
cat > {{path/to/file}}


Number all output lines:
cat {{[-n|--number]}} {{path/to/file}}


Display all characters, including tabs, line endings, and non-printing characters:
cat {{[-A|--show-all]}} {{path/to/file}}


Pass file contents to another program through stdin:
cat {{path/to/file}} | {{program}}

Code Snippets

Print the contents of a file to `stdout`

cat {{path/to/file}}

Concatenate several files into an output file

cat {{path/to/file1 path/to/file2 ...}} > {{path/to/output_file}}

Append several files to an output file

cat {{path/to/file1 path/to/file2 ...}} >> {{path/to/output_file}}

Write to a file interactively

cat > {{path/to/file}}

Number all output lines

cat {{[-n|--number]}} {{path/to/file}}

Context

tldr-pages: linux/cat

Revisions (0)

No revisions yet.