{"id":3655,"date":"2023-02-04T10:13:21","date_gmt":"2023-02-04T10:13:21","guid":{"rendered":"https:\/\/www.webhi.com\/how-to\/?p=3655"},"modified":"2023-02-04T10:13:23","modified_gmt":"2023-02-04T10:13:23","slug":"how-to-use-the-cat-command-in-linux-unix","status":"publish","type":"post","link":"https:\/\/www.webhi.com\/how-to\/how-to-use-the-cat-command-in-linux-unix\/","title":{"rendered":"How to use the Cat Command in Linux\/Unix"},"content":{"rendered":"\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"1200\" height=\"675\" src=\"https:\/\/www.webhi.com\/how-to\/gilrogre\/2023\/02\/cat_linux_en.jpg\" alt=\"Syntax and exemples for Cat (Unix command)\" class=\"wp-image-3675\" srcset=\"https:\/\/www.webhi.com\/how-to\/gilrogre\/2023\/02\/cat_linux_en.jpg 1200w, https:\/\/www.webhi.com\/how-to\/gilrogre\/2023\/02\/cat_linux_en-300x169.jpg 300w, https:\/\/www.webhi.com\/how-to\/gilrogre\/2023\/02\/cat_linux_en-1024x576.jpg 1024w, https:\/\/www.webhi.com\/how-to\/gilrogre\/2023\/02\/cat_linux_en-768x432.jpg 768w, https:\/\/www.webhi.com\/how-to\/gilrogre\/2023\/02\/cat_linux_en-150x84.jpg 150w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"introduction\">Introduction<\/h2>\n\n\n\n<p>The Linux &amp; Unix cat command is a useful utility for displaying the contents of a file, but it can do much more. It is one of the most commonly used commands in Linux, and it is often used in combination with other commands to perform powerful operations. In this guide, we will look at the basics of the cat command and its various uses.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"usage\">Usage<\/h2>\n\n\n\n<p>The&nbsp;<code>cat<\/code>&nbsp;command has the following syntax:<\/p>\n\n\n\n<p><code>cat [options] [file_name]<\/code><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"options\">Options<\/h2>\n\n\n\n<p>The&nbsp;<code>cat<\/code>&nbsp;command has several options available to use, including:<\/p>\n\n\n\n<ul><li><code>-A<\/code>: Prints out all characters, including non-printing characters<\/li><li><code>-b<\/code>: Number non-blank output lines<\/li><li><code>-E<\/code>: Display a&nbsp;<code>$<\/code>&nbsp;at the end of each line<\/li><li><code>-n<\/code>: Number all output lines<\/li><li><code>-s<\/code>: Squeeze multiple blank lines into one<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"examples\">Examples<\/h2>\n\n\n\n<p>Here are some examples of how to use the&nbsp;<code>cat<\/code>&nbsp;command:<\/p>\n\n\n\n<ul><li>To view the contents of a file:<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ cat file.txt<\/code><\/pre>\n\n\n\n<ul><li>To view the contents of multiple files:<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ cat file1 file2 file3<\/code><\/pre>\n\n\n\n<ul><li>To print out all characters, including non-printing characters:<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ cat -A filename<\/code><\/pre>\n\n\n\n<ul><li>To number all lines of output:<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ cat -n filename<\/code><\/pre>\n\n\n\n<ul><li>To squeeze multiple blank lines into one:<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">$ cat -s filename<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"conclusion\">Conclusion<\/h2>\n\n\n\n<p>The&nbsp;<code>cat<\/code>&nbsp;command is a powerful tool for viewing and manipulating files in the Linux command line. With the usage, options, and examples outlined in this guide, you should be able to get up and running quickly with the&nbsp;<code>cat<\/code>&nbsp;command.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction The Linux &amp; Unix cat command is a useful utility for displaying the contents of a file, but it can do much more. It is one of the most commonly used commands in Linux, and it is often used in combination with other commands to perform powerful operations. In this guide, we will look ..<\/p>\n<div class=\"clear-fix\"><\/div>\n<p><a href=\"https:\/\/www.webhi.com\/how-to\/how-to-use-the-cat-command-in-linux-unix\/\" title=\"read more...\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[69],"tags":[],"yoast_head":"\n<title>How to use the Cat Command in Linux\/Unix - WebHi Tutorials &amp; Documentations<\/title>\n<meta name=\"description\" content=\"Learn how to use the Linux cat command for displaying the contents of a file, as well as its various options and examples. In this guide, we will look at the basics of the cat command and its various uses.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.webhi.com\/how-to\/how-to-use-the-cat-command-in-linux-unix\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to use the Cat Command in Linux\/Unix - WebHi Tutorials &amp; Documentations\" \/>\n<meta property=\"og:description\" content=\"Learn how to use the Linux cat command for displaying the contents of a file, as well as its various options and examples. In this guide, we will look at the basics of the cat command and its various uses.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.webhi.com\/how-to\/how-to-use-the-cat-command-in-linux-unix\/\" \/>\n<meta property=\"og:site_name\" content=\"WebHi Tutorials &amp; Documentations\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webhi.technology\" \/>\n<meta property=\"article:published_time\" content=\"2023-02-04T10:13:21+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-02-04T10:13:23+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.webhi.com\/how-to\/gilrogre\/2023\/02\/cat_linux_en.jpg\" \/>\n<meta name=\"author\" content=\"webhi\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@WebHiTechnology\" \/>\n<meta name=\"twitter:site\" content=\"@WebHiTechnology\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"webhi\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"TechArticle\",\"@id\":\"https:\/\/www.webhi.com\/how-to\/how-to-use-the-cat-command-in-linux-unix\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.webhi.com\/how-to\/how-to-use-the-cat-command-in-linux-unix\/\"},\"author\":{\"name\":\"webhi\",\"@id\":\"https:\/\/www.webhi.com\/how-to\/#\/schema\/person\/b31e76e2311cdc0bb90f5e2733059a54\"},\"headline\":\"How to use the Cat Command in Linux\/Unix\",\"datePublished\":\"2023-02-04T10:13:21+00:00\",\"dateModified\":\"2023-02-04T10:13:23+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.webhi.com\/how-to\/how-to-use-the-cat-command-in-linux-unix\/\"},\"wordCount\":219,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.webhi.com\/how-to\/#organization\"},\"articleSection\":[\"Linux system administration\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.webhi.com\/how-to\/how-to-use-the-cat-command-in-linux-unix\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.webhi.com\/how-to\/how-to-use-the-cat-command-in-linux-unix\/\",\"url\":\"https:\/\/www.webhi.com\/how-to\/how-to-use-the-cat-command-in-linux-unix\/\",\"name\":\"How to use the Cat Command in Linux\/Unix - WebHi Tutorials &amp; Documentations\",\"isPartOf\":{\"@id\":\"https:\/\/www.webhi.com\/how-to\/#website\"},\"datePublished\":\"2023-02-04T10:13:21+00:00\",\"dateModified\":\"2023-02-04T10:13:23+00:00\",\"description\":\"Learn how to use the Linux cat command for displaying the contents of a file, as well as its various options and examples. In this guide, we will look at the basics of the cat command and its various uses.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.webhi.com\/how-to\/how-to-use-the-cat-command-in-linux-unix\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.webhi.com\/how-to\/how-to-use-the-cat-command-in-linux-unix\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.webhi.com\/how-to\/how-to-use-the-cat-command-in-linux-unix\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.webhi.com\/how-to\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to use the Cat Command in Linux\/Unix\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.webhi.com\/how-to\/#website\",\"url\":\"https:\/\/www.webhi.com\/how-to\/\",\"name\":\"WebHi Tutorials &amp; Documentations\",\"description\":\"System administration and knowledge base\",\"publisher\":{\"@id\":\"https:\/\/www.webhi.com\/how-to\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.webhi.com\/how-to\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.webhi.com\/how-to\/#organization\",\"name\":\"WebHi Technology\",\"url\":\"https:\/\/www.webhi.com\/how-to\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webhi.com\/how-to\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.webhi.com\/how-to\/gilrogre\/2022\/07\/logo.png\",\"contentUrl\":\"https:\/\/www.webhi.com\/how-to\/gilrogre\/2022\/07\/logo.png\",\"width\":288,\"height\":95,\"caption\":\"WebHi Technology\"},\"image\":{\"@id\":\"https:\/\/www.webhi.com\/how-to\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webhi.technology\",\"https:\/\/twitter.com\/WebHiTechnology\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.webhi.com\/how-to\/#\/schema\/person\/b31e76e2311cdc0bb90f5e2733059a54\",\"name\":\"webhi\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webhi.com\/how-to\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/www.webhi.com\/how-to\/ahuphiph\/litespeed\/avatar\/e20da107d0f4c765ead2eef88ad019d8.jpg?ver=1781214743\",\"contentUrl\":\"https:\/\/www.webhi.com\/how-to\/ahuphiph\/litespeed\/avatar\/e20da107d0f4c765ead2eef88ad019d8.jpg?ver=1781214743\",\"caption\":\"webhi\"},\"sameAs\":[\"https:\/\/www.webhi.com\/how-to\"],\"url\":\"https:\/\/www.webhi.com\/how-to\/author\/webhi\/\"}]}<\/script>\n","yoast_head_json":{"title":"How to use the Cat Command in Linux\/Unix - WebHi Tutorials &amp; Documentations","description":"Learn how to use the Linux cat command for displaying the contents of a file, as well as its various options and examples. In this guide, we will look at the basics of the cat command and its various uses.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.webhi.com\/how-to\/how-to-use-the-cat-command-in-linux-unix\/","og_locale":"en_US","og_type":"article","og_title":"How to use the Cat Command in Linux\/Unix - WebHi Tutorials &amp; Documentations","og_description":"Learn how to use the Linux cat command for displaying the contents of a file, as well as its various options and examples. In this guide, we will look at the basics of the cat command and its various uses.","og_url":"https:\/\/www.webhi.com\/how-to\/how-to-use-the-cat-command-in-linux-unix\/","og_site_name":"WebHi Tutorials &amp; Documentations","article_publisher":"https:\/\/www.facebook.com\/webhi.technology","article_published_time":"2023-02-04T10:13:21+00:00","article_modified_time":"2023-02-04T10:13:23+00:00","og_image":[{"url":"https:\/\/www.webhi.com\/how-to\/gilrogre\/2023\/02\/cat_linux_en.jpg"}],"author":"webhi","twitter_card":"summary_large_image","twitter_creator":"@WebHiTechnology","twitter_site":"@WebHiTechnology","twitter_misc":{"Written by":"webhi","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"TechArticle","@id":"https:\/\/www.webhi.com\/how-to\/how-to-use-the-cat-command-in-linux-unix\/#article","isPartOf":{"@id":"https:\/\/www.webhi.com\/how-to\/how-to-use-the-cat-command-in-linux-unix\/"},"author":{"name":"webhi","@id":"https:\/\/www.webhi.com\/how-to\/#\/schema\/person\/b31e76e2311cdc0bb90f5e2733059a54"},"headline":"How to use the Cat Command in Linux\/Unix","datePublished":"2023-02-04T10:13:21+00:00","dateModified":"2023-02-04T10:13:23+00:00","mainEntityOfPage":{"@id":"https:\/\/www.webhi.com\/how-to\/how-to-use-the-cat-command-in-linux-unix\/"},"wordCount":219,"commentCount":0,"publisher":{"@id":"https:\/\/www.webhi.com\/how-to\/#organization"},"articleSection":["Linux system administration"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.webhi.com\/how-to\/how-to-use-the-cat-command-in-linux-unix\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.webhi.com\/how-to\/how-to-use-the-cat-command-in-linux-unix\/","url":"https:\/\/www.webhi.com\/how-to\/how-to-use-the-cat-command-in-linux-unix\/","name":"How to use the Cat Command in Linux\/Unix - WebHi Tutorials &amp; Documentations","isPartOf":{"@id":"https:\/\/www.webhi.com\/how-to\/#website"},"datePublished":"2023-02-04T10:13:21+00:00","dateModified":"2023-02-04T10:13:23+00:00","description":"Learn how to use the Linux cat command for displaying the contents of a file, as well as its various options and examples. In this guide, we will look at the basics of the cat command and its various uses.","breadcrumb":{"@id":"https:\/\/www.webhi.com\/how-to\/how-to-use-the-cat-command-in-linux-unix\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.webhi.com\/how-to\/how-to-use-the-cat-command-in-linux-unix\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.webhi.com\/how-to\/how-to-use-the-cat-command-in-linux-unix\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.webhi.com\/how-to\/"},{"@type":"ListItem","position":2,"name":"How to use the Cat Command in Linux\/Unix"}]},{"@type":"WebSite","@id":"https:\/\/www.webhi.com\/how-to\/#website","url":"https:\/\/www.webhi.com\/how-to\/","name":"WebHi Tutorials &amp; Documentations","description":"System administration and knowledge base","publisher":{"@id":"https:\/\/www.webhi.com\/how-to\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.webhi.com\/how-to\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.webhi.com\/how-to\/#organization","name":"WebHi Technology","url":"https:\/\/www.webhi.com\/how-to\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webhi.com\/how-to\/#\/schema\/logo\/image\/","url":"https:\/\/www.webhi.com\/how-to\/gilrogre\/2022\/07\/logo.png","contentUrl":"https:\/\/www.webhi.com\/how-to\/gilrogre\/2022\/07\/logo.png","width":288,"height":95,"caption":"WebHi Technology"},"image":{"@id":"https:\/\/www.webhi.com\/how-to\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webhi.technology","https:\/\/twitter.com\/WebHiTechnology"]},{"@type":"Person","@id":"https:\/\/www.webhi.com\/how-to\/#\/schema\/person\/b31e76e2311cdc0bb90f5e2733059a54","name":"webhi","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webhi.com\/how-to\/#\/schema\/person\/image\/","url":"https:\/\/www.webhi.com\/how-to\/ahuphiph\/litespeed\/avatar\/e20da107d0f4c765ead2eef88ad019d8.jpg?ver=1781214743","contentUrl":"https:\/\/www.webhi.com\/how-to\/ahuphiph\/litespeed\/avatar\/e20da107d0f4c765ead2eef88ad019d8.jpg?ver=1781214743","caption":"webhi"},"sameAs":["https:\/\/www.webhi.com\/how-to"],"url":"https:\/\/www.webhi.com\/how-to\/author\/webhi\/"}]}},"_links":{"self":[{"href":"https:\/\/www.webhi.com\/how-to\/wp-json\/wp\/v2\/posts\/3655"}],"collection":[{"href":"https:\/\/www.webhi.com\/how-to\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webhi.com\/how-to\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webhi.com\/how-to\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webhi.com\/how-to\/wp-json\/wp\/v2\/comments?post=3655"}],"version-history":[{"count":7,"href":"https:\/\/www.webhi.com\/how-to\/wp-json\/wp\/v2\/posts\/3655\/revisions"}],"predecessor-version":[{"id":3687,"href":"https:\/\/www.webhi.com\/how-to\/wp-json\/wp\/v2\/posts\/3655\/revisions\/3687"}],"wp:attachment":[{"href":"https:\/\/www.webhi.com\/how-to\/wp-json\/wp\/v2\/media?parent=3655"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webhi.com\/how-to\/wp-json\/wp\/v2\/categories?post=3655"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webhi.com\/how-to\/wp-json\/wp\/v2\/tags?post=3655"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}