cat
The shell command that prints the contents of one or more files to the terminal.
In more detail
Its name comes from concatenate, because given several files it prints them one after another. It is the quickest way to look at a small text file without opening an editor.
Examples
cat by-hand/server.conf reveals the duplicated line a script appended twice.cat out.txtcat .git/HEADThe name comes from concatenate, because it can join several files into one stream. On Linux it is the quickest way to read small text files and live kernel files, such as cat /proc/cmdline. Its output reflects the file at the moment of reading, which for /proc and /sys can change between runs.Related terms
- shell — The program that reads the commands you type, runs them and shows the results; sh and bash are common ones.
- here document — A way to write several lines of text straight into a script or file, opened with << and a marker word such as EOF and closed by that word on its own line.
- head — The command that prints the first lines of its input, ten by default or as many as -n says.
- pipe — The | operator, which connects one command's standard output to the next command's standard input so they run together.
- /proc filesystem — A virtual folder the Linux kernel fills with live information about processes and the system.
- sysfs — A virtual filesystem mounted at /sys where the kernel exposes devices, drivers and their settings as files.
- standard output and standard error — The two channels a program writes normal output (stdout) and error messages (stderr) to, plus stdin for input.
Taught in
- What Configuration Management Is — Ansible Configuration Management at Scale
- Moving Around: pwd, ls, cd And Paths — Bash Scripting & Command Line Automation
- Making, Copying, Moving And Removing — Bash Scripting & Command Line Automation
- The Unquoted Variable: Splitting And Globbing — Bash Scripting & Command Line Automation
- Redirection: Truncate, Append, Both Streams — Bash Scripting & Command Line Automation
- Pipelines, tee And Process Substitution — Bash Scripting & Command Line Automation
- Shell Variables, The Environment And export — Bash Scripting & Command Line Automation
- Script Input And Output: read, Heredocs, printf — Bash Scripting & Command Line Automation
- set -e, set -u And pipefail: Promises And Traps — Bash Scripting & Command Line Automation
- POSIX sh Versus Bash — Bash Scripting & Command Line Automation
- Permissions And Ownership — Bash Scripting & Command Line Automation
- Archives, Transfers And The Network — Bash Scripting & Command Line Automation
- Why Version Control, And Why Git Won — Advanced Git Internals & Distributed Workflows
- Installing Git, And Telling It Who You Are — Advanced Git Internals & Distributed Workflows
- A Repository Is A Folder With A Memory — Advanced Git Internals & Distributed Workflows
- The Three Areas: Working Tree, Index, Repository — Advanced Git Internals & Distributed Workflows
- Committing, And What A Good Message Says — Advanced Git Internals & Distributed Workflows
- A Branch Is A Moving Pointer — Advanced Git Internals & Distributed Workflows
- HEAD, And Why Detached HEAD Is Not An Error — Advanced Git Internals & Distributed Workflows
- Undoing: restore, reset, revert And stash — Advanced Git Internals & Distributed Workflows
- What A Remote Actually Is — Advanced Git Internals & Distributed Workflows
- Resolving A Conflict, Line By Line — Advanced Git Internals & Distributed Workflows
- Everything Is A File: proc, sys And dev — Linux Fundamentals & Systems Administration
- Packages And Repositories: yum_repository And dnf — RHCE in Ansible (EX294): Automate Red Hat Systems
- Ansible Vault: Secrets Encrypted, Runs Without A Prompt — RHCE in Ansible (EX294): Automate Red Hat Systems