Cat command

From Linux Bash Shell Scripting Tutorial Wiki
Jump to navigation Jump to search

The cat command is used to concatenate files and display on the standard output (screen).

Quick File Creation With cat

Type the following command to create a file called demo.txt:

cat > demo.txt

Sample session:

This is a demo.
This is a test.
[Press CTRL+D to save the file]
  • cat copies to standard output. To save the changes hit ctrl+d, which goes to the file demo.txt

Quickly View File With cat

Type the following command:

cat /etc/passwd

Number All Output Lines

cat -n /etc/passwd

Shell All Including Tabs and Nonprinting Characters

cat -A /path/to/file

Recommend Readings

You can view cat command man page by typing the following man command at a shell prompt:

man cat

See also