# cat – Unix and Linux Command with Examples

Published On: August 24th, 2015|Last Updated: January 7th, 2023|Categories: UNIX & Linux|Total Views: 1171|Daily Views: 1|

### DESCRIPTION:

cat command is one of the basic utility in UNIX operating system to concatenate files.

### USAGE:

cat command is used to

• View the full content of the file in the screen.
• copy the file
• append the content of the file to another file

### OPTIONS & USE CASES:

Totally there are 11 options to use with cat command. These options may or may not be available for different versions of UNIX operating systems. Below you can find all the 11 cat command options with example. Here I took a file named cat_example.txt as an example.

```cat -A cat_example.txt

ABC DEF GHI
JKL MNO PQR
STU VWX YZ```

### -A or –show-all

This option shows all the non-printing characters (^ and M-), TABS as ^I and shows \$ at end of the each line. In short, this option equals to -vET options. Both –A and –show-all provides same result.

-A = –show-all = -vET

Example: Tabs are displayed as ^I character and \$ is displayed at end of the each line. Mostly ^M (Ctrl+M) occurs when the text file is transferred in the binary mode.

## Read More:Find and remove ^M (control+M) characters in unix

\$

```cat -A cat_example­.txt
ABC^IDEF^IGHI^M\$
^M\$
JKL^IMNO^IPQR^M\$
^M\$
^M\$
STU^IVWX^IYZ^M\$```

### -b or –number-nonblank

This option used to display line numbers only in the non-empty lines.

\$ cat -b cat_example.txt

```1 ABC     DEF     GHI

2 JKL     MNO     PQR

3 STU     VWX     YZ```

### -e

It is equivalent to –vE option. It displays all the non-printing characters (^ and M-) and displays \$ at the end of each line

-e = -vE

```\$ cat -e cat_example.txt
ABC     DEF     GHI^M\$
^M\$
JKL     MNO     PQR^M\$
^M\$
^M\$
STU     VWX     YZ^M\$```

### -E, –show-ends

Displays \$ symbol at the end of each line.

```\$ cat -E cat_example.txt
ABC     DEF     GHI\$
\$
JKL     MNO     PQR\$
\$
\$
STU     VWX     YZ\$```

### -n, –number

Displays line number in all the lines even it is a empty line.

```\$ cat -n cat_example.txt
1 ABC     DEF     GHI
2
3 JKL     MNO     PQR
4
5
6 STU     VWX     YZ```

### -s, –squeeze-blank

It combines more than one empty lines to one empty line. In the below example, you can see 4th and 5th empty lines are combined to one empty line.

```\$ cat –s cat_example.txt
ABC     DEF     GHI

JKL     MNO     PQR

STU     VWX     YZ```

### -t

This option shows all the non-printing characters (^ and M-) and TABS as ^I. It is equivalent to –vT.

```\$ cat -t cat_example­.txt
ABC^IDEF^IGHI^M
^M
JKL^IMNO^IPQR^M
^M
^M
STU^IVWX^IYZ^M```

### -T, –show-tabs

Displays TAB space as ^I in the file.

```\$ cat -T cat_example­.txt
ABC^IDEF^IGHI

JKL^IMNO^IPQR

STU^IVWX^IYZ```

### -v, –show-nonprinting

Displays the non-printing characters (^ and M-) in the files.

```\$ cat -e cat_example.txt
ABC     DEF     GHI^M
^M
JKL     MNO     PQR^M
^M
^M
STU     VWX     YZ^M```

### – -help

It displays the manual page of cat command which includes usage, options and example of cat command. It just displays the help infirmation and exit.

`\$ cat --help`

### – -version

Displays version, license and author of cat command. Like –help option, it too displays the version information and exit.

`\$ cat --version`

You have any doubts or feedback? Let us know in the comments below.

1. •
{"ft_lang_label":"__label__en","ft_lang_prob":0.71655744,"math_prob":0.47774458,"size":2998,"snap":"2023-40-2023-50","text_gpt3_token_len":901,"char_repetition_ratio":0.1506346,"word_repetition_ratio":0.08103131,"special_character_ratio":0.26617745,"punctuation_ratio":0.08785942,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.96297747,"pos_list":[0,1,2,3,4],"im_url_duplicate_count":[null,null,null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-11-29T18:11:01Z\",\"WARC-Record-ID\":\"<urn:uuid:2282c8c2-1af1-4a4d-ad2b-9c42a383a83a>\",\"Content-Length\":\"223602\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:81823376-b7e9-4f03-b9ab-23a2e08e003c>\",\"WARC-Concurrent-To\":\"<urn:uuid:09dea69e-0761-4ab2-8d80-6be54420f306>\",\"WARC-IP-Address\":\"172.67.186.14\",\"WARC-Target-URI\":\"https://spytm.com/cat-unix-and-linux-command-with-examples/\",\"WARC-Payload-Digest\":\"sha1:OTROQMMWYRU246YDE5IWMTAHZ5INLFP4\",\"WARC-Block-Digest\":\"sha1:CLBT3PJBY7CHDYP2DBYGERIEPJONXTOO\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-50/CC-MAIN-2023-50_segments_1700679100135.11_warc_CC-MAIN-20231129173017-20231129203017-00647.warc.gz\"}"}