UnixDroid

Text · Linux command

cat command in Linux

What does cat do?

cat prints the whole content of one or more files to the screen. It is also used to join files together.

cat [options] file…

Most useful options

OptionWhat it does
-nnumber every line
-Ashow hidden characters (tabs, line ends)

cat examples

$ cat notes.txt Try it ›

show a file

$ cat -n script.sh Try it ›

show with line numbers

$ cat a.txt b.txt > both.txt Try it ›

join two files

In security work

Use cat for short files; for long logs, less or tail is faster.

Questions about cat

What is the difference between cat and less?

cat dumps the whole file at once; less lets you scroll and search page by page — better for big files.