{"id":15648,"date":"2019-02-25T14:48:38","date_gmt":"2019-02-25T14:48:38","guid":{"rendered":"https:\/\/www.hostinger.com\/tutorials\/?p=15648"},"modified":"2025-02-24T14:01:35","modified_gmt":"2025-02-24T14:01:35","slug":"linux-cat-command","status":"publish","type":"post","link":"\/uk\/tutorials\/linux-cat-command","title":{"rendered":"How to use the Linux cat command"},"content":{"rendered":"<p>The <strong>cat<\/strong> command is one of the most useful commands in Linux &ndash; it is used for displaying, combining, and manipulating text files.<\/p><p>Its versatility is what makes it an indispensable tool for everyday Linux administration and scripting. For instance, it can be used to quickly view the contents of configuration files inside the <strong>\/etc<\/strong> directory or, concatenate multiple files into one.<\/p><p>What&rsquo;s more, the <strong>cat<\/strong> command comes pre-installed with the <strong>coreutils<\/strong> package in any Debian and Red Hat-based system, so you don&rsquo;t need to install it separately.<\/p><p>In this tutorial, we will go through the essential and common uses of the Linux <strong>cat<\/strong> command and explain its features with examples.<\/p><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/assets.hostinger.com\/content\/tutorials\/pdf\/Linux-Commands-Cheat-Sheet.pdf\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" width=\"1024\" height=\"283\" src=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2022\/11\/Linux-cheat-sheet-1024x283.png\" alt=\"\" class=\"wp-image-69262\" srcset=\"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2022\/11\/Linux-cheat-sheet-1536x425.png 1024w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2022\/11\/Linux-cheat-sheet-300x83.png 300w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2022\/11\/Linux-cheat-sheet-150x41.png 150w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2022\/11\/Linux-cheat-sheet-768x212.png 768w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2022\/11\/Linux-cheat-sheet.png 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div><p>\n\n\n\n\n\n<\/p><h2 class=\"wp-block-heading\" id=\"h-syntax-of-the-cat-command\">Syntax of the cat command<\/h2><p>Before we start to deep-dive into the article&rsquo;s subject, you should log into the VPS using <a href=\"\/uk\/tutorials\/how-to-use-putty-ssh\">SSH<\/a>, to run the below <strong>cat<\/strong> commands and check its basic syntax.<\/p><p>The basic syntax of the <strong>cat<\/strong> command is:<\/p><pre class=\"wp-block-preformatted\">cat [OPTION] [FILENAME]<\/pre><p>The command takes the name of one or more files you want to look at or change as an argument, along with the additional settings that change how the command works.<\/p><p>Here&rsquo;s a breakdown of each part of the command:<\/p><ul class=\"wp-block-list\">\n<li><strong>cat<\/strong>: This is the command itself. It stands for &ldquo;concatenate&rdquo; and is used to read and display the contents of files.<\/li>\n\n\n\n<li><strong>[OPTION]:<\/strong> These are optional flags that modify the behavior of the<strong> cat<\/strong> command. For example, <strong>-n<\/strong> adds line numbers to the output, and <strong>-s<\/strong> squeezes multiple adjacent blank lines into a single blank line. Later in the tutorial, we will demonstrate how to use these options to perform particular operations.<\/li>\n\n\n\n<li><strong>[FILENAME]<\/strong>: This is the name of one or more files that you want to view or manipulate. You can list multiple filenames separated by spaces to concatenate their contents.<\/li>\n<\/ul><p>To find all available options for the <strong>cat<\/strong> command, just type <strong>cat &ndash;help <\/strong>in your terminal or use the cat command manual using the command below:<\/p><pre class=\"wp-block-preformatted\">man cat&nbsp;<\/pre><p>This is what the manual&rsquo;s page for the cat command looks like:<\/p><div class=\"wp-block-image\">\n<figure data-wp-context='{\"imageId\":\"69e08b0baa230\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-large wp-lightbox-container\"><img decoding=\"async\" width=\"1024\" height=\"553\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2024\/07\/cat-command-user-commands-1024x553.png\" alt=\"User manual for the cat command\" class=\"wp-image-113531\" srcset=\"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2024\/07\/cat-command-user-commands-1024x553.png 1024w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2024\/07\/cat-command-user-commands-300x162.png 300w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2024\/07\/cat-command-user-commands-150x81.png 150w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2024\/07\/cat-command-user-commands-768x414.png 768w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2024\/07\/cat-command-user-commands-1536x829.png 1536w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2024\/07\/cat-command-user-commands-2048x1105.png 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><p>This manual page provides in-depth information about the <strong>cat <\/strong>command, including its name, synopsis, and description. It also outlines the different options that can be utilized with the<strong> cat <\/strong>command. This page is a helpful resource for understanding the various available options and the operations they perform.<\/p><h2 class=\"wp-block-heading\" id=\"h-common-use-cases-and-examples-of-the-linux-cat-command\">Common use cases and examples of the Linux cat command<\/h2><p>The Linux cat command can be used in various situations to perform essential tasks. Here are a few examples.<\/p><h3 class=\"wp-block-heading\" id=\"h-displaying-file-contents\">Displaying file contents<\/h3><p>It is one of the most basic and common uses of the <strong>cat<\/strong> command. If you want to see what&rsquo;s inside a file, simply use the command:<\/p><pre class=\"wp-block-preformatted\">cat filename.txt<br><br>cat<\/pre><div class=\"wp-block-image\">\n<figure data-wp-context='{\"imageId\":\"69e08b0bacca2\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-full wp-lightbox-container\"><img decoding=\"async\" width=\"908\" height=\"118\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2024\/07\/filename.png\" alt=\"Terminal window showing the output of the cat filename.txt command, to display the content of the file\" class=\"wp-image-113532\" srcset=\"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2024\/07\/filename.png 908w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2024\/07\/filename-300x39.png 300w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2024\/07\/filename-150x19.png 150w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2024\/07\/filename-768x100.png 768w\" sizes=\"(max-width: 908px) 100vw, 908px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><p>This command will display all the contents of <strong>filename.txt<\/strong> right in your terminal. It&rsquo;s perfect for quickly checking small files without opening a text editor.<\/p><p>One of the most practical uses of this command is to view the contents of configuration files inside the <strong>\/etc<\/strong> directory and quickly check the content of log files inside the <strong>\/var\/log <\/strong>directory.<\/p><p>We can use the following command to display the content of multiple files of the same format:<\/p><pre class=\"wp-block-preformatted\">cat *.txt<\/pre><p>To prevent scrolling large files add the option <strong>| more<\/strong> to the end of the command. It reads the file content page by page, making it easier to navigate through large text files.<\/p><pre class=\"wp-block-preformatted\">cat filename.txt | more<\/pre><div class=\"wp-block-image\">\n<figure data-wp-context='{\"imageId\":\"69e08b0baf5d5\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-large wp-lightbox-container\"><img decoding=\"async\" width=\"1024\" height=\"108\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2024\/07\/filename-more-1024x108.png\" alt=\"Terminal window showing the output of cat filename.txt | more command\" class=\"wp-image-113533\" srcset=\"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2024\/07\/filename-more-1024x108.png 1024w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2024\/07\/filename-more-300x32.png 300w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2024\/07\/filename-more-150x16.png 150w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2024\/07\/filename-more-768x81.png 768w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2024\/07\/filename-more.png 1118w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><h3 class=\"wp-block-heading\" id=\"h-displaying-multiple-files\">Displaying multiple files<\/h3><p>Instead of displaying the contents of a single file in the console, you can use the following command to display the content of multiple files:<\/p><pre class=\"wp-block-preformatted\">cat file1.txt file2.txt file3.txt<\/pre><div class=\"wp-block-image\">\n<figure data-wp-context='{\"imageId\":\"69e08b0bb20c5\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-full wp-lightbox-container\"><img decoding=\"async\" width=\"944\" height=\"144\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2024\/07\/cat-command-multiple-files.png\" alt=\"Terminal window showing the output of the cat file1.txt file2.txt file3.txt command\" class=\"wp-image-113534\" srcset=\"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2024\/07\/cat-command-multiple-files.png 944w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2024\/07\/cat-command-multiple-files-300x46.png 300w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2024\/07\/cat-command-multiple-files-150x23.png 150w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2024\/07\/cat-command-multiple-files-768x117.png 768w\" sizes=\"(max-width: 944px) 100vw, 944px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><p>It is great for comparing files or getting a quick overview of multiple files at once.<\/p><h3 class=\"wp-block-heading\" id=\"h-creating-new-files\">Creating new files<\/h3><p>We can use the <strong>cat<\/strong> command to create new files and easily add data to them. This can be particularly useful for quickly generating and filling text files without needing to open a separate text editor.<\/p><p>The below command is useful for creating text files and writing scripts or configuration files directly from the command line.<\/p><pre class=\"wp-block-preformatted\">cat &gt; newfile.txt<\/pre><div class=\"wp-block-image\">\n<figure data-wp-context='{\"imageId\":\"69e08b0bb4c49\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-full wp-lightbox-container\"><img decoding=\"async\" width=\"670\" height=\"90\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2024\/07\/cat-command-new-file.png\" alt=\"Terminal window showing the output of the cat &gt; newfile.txt command\" class=\"wp-image-113535\" srcset=\"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2024\/07\/cat-command-new-file.png 670w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2024\/07\/cat-command-new-file-300x40.png 300w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2024\/07\/cat-command-new-file-150x20.png 150w\" sizes=\"(max-width: 670px) 100vw, 670px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><p>After running this command, a new file is created, and you can begin populating it with text. To add multiple lines of text, just press <strong>Enter<\/strong> at the end of each line. Once you&rsquo;re done, hit <strong>CTRL+D<\/strong> then <strong>CTRL+C <\/strong>to save and exit the file.<\/p><p>Voila! You&rsquo;ve created a new file. If the destination file does not exist, this command will create it or overwrite the existing one with the same name.<\/p><h3 class=\"wp-block-heading\" id=\"h-appending-to-files\">Appending to files<\/h3><p>To add more data to an existing file, we can use the <strong>cat<\/strong> command with the append<strong> &gt;&gt; <\/strong>operator:<\/p><pre class=\"wp-block-preformatted\">cat &gt;&gt; filename.txt<\/pre><p>Simply enter some text and press <strong>Ctrl+D<\/strong> to save.<\/p><div class=\"wp-block-image\">\n<figure data-wp-context='{\"imageId\":\"69e08b0bb74b9\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-full wp-lightbox-container\"><img decoding=\"async\" width=\"714\" height=\"90\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2024\/07\/cat-command-append-data.png\" alt=\"Terminal window showing the output of the cat &gt;&gt; filename.txt command\" class=\"wp-image-113536\" srcset=\"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2024\/07\/cat-command-append-data.png 714w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2024\/07\/cat-command-append-data-300x38.png 300w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2024\/07\/cat-command-append-data-150x19.png 150w\" sizes=\"(max-width: 714px) 100vw, 714px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><p>To verify if the newly added data has been appended to the file, let&rsquo;s use the <strong>cat<\/strong> command:<\/p><pre class=\"wp-block-preformatted\">cat filename.txt<\/pre><div class=\"wp-block-image\">\n<figure data-wp-context='{\"imageId\":\"69e08b0bb98ca\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-full wp-lightbox-container\"><img decoding=\"async\" width=\"658\" height=\"112\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2024\/07\/cat-command-append-data-output.png\" alt=\"Terminal window showing the contents of the filename.txt file after appending data to it\" class=\"wp-image-113538\" srcset=\"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2024\/07\/cat-command-append-data-output.png 658w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2024\/07\/cat-command-append-data-output-300x51.png 300w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2024\/07\/cat-command-append-data-output-150x26.png 150w\" sizes=\"(max-width: 658px) 100vw, 658px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><p>This command is useful for appending text and configurations to existing files or adding entries to log files.<\/p><h3 class=\"wp-block-heading\" id=\"h-displaying-line-numbers\">Displaying line numbers<\/h3><p>Sometimes, it&rsquo;s helpful to see line numbers alongside the content. To use this feature, use the <strong>-n<\/strong> option with the <strong>cat<\/strong> command:<\/p><pre class=\"wp-block-preformatted\">cat -n filename.txt<\/pre><div class=\"wp-block-image\">\n<figure data-wp-context='{\"imageId\":\"69e08b0bc74de\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-full wp-lightbox-container\"><img decoding=\"async\" width=\"736\" height=\"114\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2024\/07\/cat-command-append-data-output-line-number-1.png\" alt=\"Terminal window showing the output of the cat -n filename.txt command to display the line numbers\" class=\"wp-image-113539\" srcset=\"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2024\/07\/cat-command-append-data-output-line-number-1.png 736w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2024\/07\/cat-command-append-data-output-line-number-1-300x46.png 300w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2024\/07\/cat-command-append-data-output-line-number-1-150x23.png 150w\" sizes=\"(max-width: 736px) 100vw, 736px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><p>This technique is especially useful for debugging scripts by referencing line numbers or reviewing code with line references.<\/p><h3 class=\"wp-block-heading\" id=\"h-suppressing-repeated-empty-lines\">Suppressing repeated empty lines<\/h3><p>To suppress repeated blank lines in the output, you can use the <strong>-s<\/strong> option along with the Linux <strong>cat<\/strong> command. Do note that this option will keep one blank line by removing the repeated blank lines only. The command would look like this:<\/p><pre class=\"wp-block-preformatted\">cat -s filename.txt<\/pre><p>This is useful for cleaning up file output and formatting documents and files for better readability.<\/p><div class=\"wp-block-image\">\n<figure data-wp-context='{\"imageId\":\"69e08b0bca41f\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-full wp-lightbox-container\"><img decoding=\"async\" width=\"706\" height=\"200\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2024\/07\/terminal-window-showing-the-output-of-the-cat-n-filename-txt-command-to-view-the-repeated-empty-lines.png\" alt=\"Terminal window showing the output of the cat -n filename.txt command to view the repeated empty lines\" class=\"wp-image-113540\" srcset=\"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2024\/07\/terminal-window-showing-the-output-of-the-cat-n-filename-txt-command-to-view-the-repeated-empty-lines.png 706w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2024\/07\/terminal-window-showing-the-output-of-the-cat-n-filename-txt-command-to-view-the-repeated-empty-lines-300x85.png 300w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2024\/07\/terminal-window-showing-the-output-of-the-cat-n-filename-txt-command-to-view-the-repeated-empty-lines-150x42.png 150w\" sizes=\"(max-width: 706px) 100vw, 706px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><div class=\"wp-block-image\">\n<figure data-wp-context='{\"imageId\":\"69e08b0bccb73\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-full wp-lightbox-container\"><img decoding=\"async\" width=\"700\" height=\"138\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2024\/07\/terminal-window-showing-the-output-of-the-cat-s-filename-txt-command-to-suppress-repeated-empty-lines.png\" alt=\"Terminal window showing the output of the cat -s filename.txt command to suppress repeated empty lines\" class=\"wp-image-113541\" srcset=\"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2024\/07\/terminal-window-showing-the-output-of-the-cat-s-filename-txt-command-to-suppress-repeated-empty-lines.png 700w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2024\/07\/terminal-window-showing-the-output-of-the-cat-s-filename-txt-command-to-suppress-repeated-empty-lines-300x59.png 300w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2024\/07\/terminal-window-showing-the-output-of-the-cat-s-filename-txt-command-to-suppress-repeated-empty-lines-150x30.png 150w\" sizes=\"(max-width: 700px) 100vw, 700px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><p>In the above output, you can see that the file <strong>filename.txt<\/strong> contains six lines, and the last three lines are empty. The <strong>-s<\/strong> option combines multiple adjacent empty lines into a single empty line, making the output cleaner and more readable.<\/p><h3 class=\"wp-block-heading\" id=\"h-showing-tabs-and-end-of-lines\">Showing tabs and end of lines<\/h3><p>When you need to see invisible characters, such as tabs and the end of lines, you can use the options <strong>-T<\/strong> and <strong>-E<\/strong> options together. The <strong>cat<\/strong> command marks line ends by displaying the <strong>$<\/strong> character at the end of each line, and it shows tab characters as <strong>^I<\/strong>.<\/p><pre class=\"wp-block-preformatted\">cat -T -E filename.txt<\/pre><p>Using both options together will display the contents of <strong>filename.txt<\/strong> with visible indicators for tabs and end of lines. This can be especially useful for:<\/p><ul class=\"wp-block-list\">\n<li>Identifying and correcting tab and space inconsistencies.<\/li>\n\n\n\n<li>Ensuring that file formatting is consistent, especially in code or configuration files where such details matter.<\/li>\n\n\n\n<li>Debugging issues where invisible characters may be causing problems in scripts or data processing.<\/li>\n<\/ul><h3 class=\"wp-block-heading\" id=\"h-redirecting-to-a-new-file\">Redirecting to a new file<\/h3><p>You can redirect the output of one file to another file using the <strong>&gt; <\/strong>redirect operator. The command looks like this:<\/p><pre class=\"wp-block-preformatted\">cat file1.txt &gt; file4.txt<\/pre><div class=\"wp-block-image\">\n<figure data-wp-context='{\"imageId\":\"69e08b0bcf745\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-full wp-lightbox-container\"><img decoding=\"async\" width=\"742\" height=\"90\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2024\/07\/terminal-window-showing-the-output-of-the-cat-command-to-redirect-data-in-file1-to-file4.png\" alt=\"Terminal window showing the output of the cat command to redirect data in file1 to file4\" class=\"wp-image-113542\" srcset=\"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2024\/07\/terminal-window-showing-the-output-of-the-cat-command-to-redirect-data-in-file1-to-file4.png 742w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2024\/07\/terminal-window-showing-the-output-of-the-cat-command-to-redirect-data-in-file1-to-file4-300x36.png 300w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2024\/07\/terminal-window-showing-the-output-of-the-cat-command-to-redirect-data-in-file1-to-file4-150x18.png 150w\" sizes=\"(max-width: 742px) 100vw, 742px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><p>This command is useful for creating backups of files and redirecting output to a new file. If the destination file does not exist, this command will create it or overwrite an existing one with the same name.<\/p><h3 class=\"wp-block-heading\" id=\"h-combining-and-redirecting-multiple-files\">Combining and redirecting multiple files<\/h3><p>To combine multiple files and redirect the output to a new file, you can use the below command:<\/p><pre class=\"wp-block-preformatted\">cat file1.txt file2.txt file3.txt &gt; combinedfile.txt<\/pre><p>This command concatenates multiple files into a single file. It functions exactly like the redirection feature above but with multiple source files.<\/p><div class=\"wp-block-image\">\n<figure data-wp-context='{\"imageId\":\"69e08b0bd200f\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-large wp-lightbox-container\"><img decoding=\"async\" width=\"1024\" height=\"135\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2024\/07\/terminal-window-showing-the-output-of-the-cat-command-to-combine-multiple-files-and-redirect-the-output-to-a-new-file-1024x135.png\" alt=\"Terminal window showing the output of the cat command to combine multiple files and redirect the output to a new file\" class=\"wp-image-113543\" srcset=\"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2024\/07\/terminal-window-showing-the-output-of-the-cat-command-to-combine-multiple-files-and-redirect-the-output-to-a-new-file-1024x135.png 1024w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2024\/07\/terminal-window-showing-the-output-of-the-cat-command-to-combine-multiple-files-and-redirect-the-output-to-a-new-file-300x40.png 300w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2024\/07\/terminal-window-showing-the-output-of-the-cat-command-to-combine-multiple-files-and-redirect-the-output-to-a-new-file-150x20.png 150w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2024\/07\/terminal-window-showing-the-output-of-the-cat-command-to-combine-multiple-files-and-redirect-the-output-to-a-new-file-768x101.png 768w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2024\/07\/terminal-window-showing-the-output-of-the-cat-command-to-combine-multiple-files-and-redirect-the-output-to-a-new-file.png 1062w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><p>It is useful when merging log files and combining configuration files.<\/p><p>To append the contents of the source file to an existing file, you can use the append <strong>&gt;&gt;<\/strong> operator along with the <strong>cat<\/strong> command to avoid overwriting it.<\/p><pre class=\"wp-block-preformatted\">cat file2.txt file3.txt &gt;&gt; file1.txt<\/pre><div class=\"wp-block-image\">\n<figure data-wp-context='{\"imageId\":\"69e08b0bd47de\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-full wp-lightbox-container\"><img decoding=\"async\" width=\"1014\" height=\"142\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2024\/07\/terminal-window-showing-the-output-of-the-cat-command-to-append-the-contents-of-multiple-source-files-to-an-existing-file.png\" alt=\"Terminal window showing the output of the cat command to append the contents of the multiple source files to an existing file\" class=\"wp-image-113544\" srcset=\"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2024\/07\/terminal-window-showing-the-output-of-the-cat-command-to-append-the-contents-of-multiple-source-files-to-an-existing-file.png 1014w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2024\/07\/terminal-window-showing-the-output-of-the-cat-command-to-append-the-contents-of-multiple-source-files-to-an-existing-file-300x42.png 300w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2024\/07\/terminal-window-showing-the-output-of-the-cat-command-to-append-the-contents-of-multiple-source-files-to-an-existing-file-150x21.png 150w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2024\/07\/terminal-window-showing-the-output-of-the-cat-command-to-append-the-contents-of-multiple-source-files-to-an-existing-file-768x108.png 768w\" sizes=\"(max-width: 1014px) 100vw, 1014px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><?xml encoding=\"utf-8\" ?><figure class=\"wp-block-image size-large\"><a href=\"\/uk\/vps-hosting\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" width=\"1024\" height=\"300\" src=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2023\/02\/VPS-hosting-banner-1024x300.png\" alt=\"\" class=\"wp-image-77934\" srcset=\"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2023\/02\/VPS-hosting-banner.png 1024w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2023\/02\/VPS-hosting-banner-300x88.png 300w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2023\/02\/VPS-hosting-banner-150x44.png 150w, https:\/\/www.hostinger.com\/uk\/tutorials\/wp-content\/uploads\/sites\/51\/2023\/02\/VPS-hosting-banner-768x225.png 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><h2 class=\"wp-block-heading\" id=\"h-conclusion\">Conclusion<\/h2><p>The Linux <strong>cat<\/strong> command might seem simple at first, but as you&rsquo;ve seen, it&rsquo;s a versatile command line tool. From viewing and creating files to combining and manipulating them, the <strong>cat<\/strong> command is often the fastest and most reliable alternative.<\/p><p>Remember, the best way to become comfortable with the <strong>cat<\/strong> command is to use it regularly.<\/p><p>Practice using the <strong>cat<\/strong> command with different options to explore its full potential and enhance your command-line skills. As a next step, learn how to master other basic <a href=\"\/uk\/tutorials\/linux-commands\">Linux commands<\/a>.<\/p><h2 class=\"wp-block-heading\" id=\"h-linux-cat-command-faq\">Linux cat command FAQ<\/h2><div class=\"schema-faq wp-block-yoast-faq-block\"><div class=\"schema-faq-section\" id=\"faq-question-1722337706522\"><h3 class=\"schema-faq-question\">What does the cat command do in Linux?<\/h3> <p class=\"schema-faq-answer\">The cat command in Linux is primarily used to display file contents, concatenate files, and create new files. It can also append text to existing files, number lines, and reveal non-printing characters.<\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1722337712063\"><h3 class=\"schema-faq-question\">Can I use the cat command to display multiple files at once?<\/h3> <p class=\"schema-faq-answer\">Yes, just list the filenames as arguments, separated by spaces. For example,<strong> cat file1.txt file2.txt file3.txt<\/strong> will display the content of all three files in sequence.<\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1722337717463\"><h3 class=\"schema-faq-question\">Can I use the cat command to display invisible characters like tabs and line endings?<\/h3> <p class=\"schema-faq-answer\">Yes, use the <strong>-T<\/strong> option for tabs and the <strong>-E<\/strong> option for line endings: <strong>cat -T -E filename.txt<\/strong>. Combining these will display all non-printing characters, which is great for troubleshooting.<\/p> <\/div> <\/div>\n","protected":false},"excerpt":{"rendered":"<p>The cat command is one of the most useful commands in Linux &ndash; it is used for displaying, combining, and manipulating text files. Its versatility is what makes it an indispensable tool for everyday Linux administration and scripting. For instance, it can be used to quickly view the contents of configuration files inside the \/etc [&#8230;]<\/p>\n<p><a class=\"btn btn-secondary understrap-read-more-link\" href=\"\/uk\/tutorials\/linux-cat-command\">Read More&#8230;<\/a><\/p>\n","protected":false},"author":449,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_title":"How to Use the Linux cat Command With Examples","rank_math_description":"The Linux cat command is a useful tool for every system administrator or Linux enthusiast. Start using it now with this helpful tutorial.","rank_math_focus_keyword":"cat command","footnotes":""},"categories":[22644,22640],"tags":[],"class_list":["post-15648","post","type-post","status-publish","format-standard","hentry","category-managing-monitoring-and-security","category-vps"],"hreflangs":[{"locale":"en-US","link":"https:\/\/www.hostinger.com\/tutorials\/linux-cat-command","default":0},{"locale":"fr-FR","link":"https:\/\/www.hostinger.com\/fr\/tutoriels\/commande-cat-linux","default":0},{"locale":"es-ES","link":"https:\/\/www.hostinger.com\/es\/tutoriales\/comando-cat-linux","default":0},{"locale":"id-ID","link":"https:\/\/www.hostinger.com\/id\/tutorial\/cat-command-linux","default":0},{"locale":"nl-NL","link":"https:\/\/www.hostinger.com\/nl\/tutorials\/linux-cat-command","default":0},{"locale":"en-UK","link":"https:\/\/www.hostinger.com\/uk\/tutorials\/linux-cat-command","default":0},{"locale":"en-MY","link":"https:\/\/www.hostinger.com\/my\/tutorials\/linux-cat-command","default":0},{"locale":"en-PH","link":"https:\/\/www.hostinger.com\/ph\/tutorials\/linux-cat-command","default":0},{"locale":"es-MX","link":"https:\/\/www.hostinger.com\/mx\/tutoriales\/comando-cat-linux","default":0},{"locale":"es-CO","link":"https:\/\/www.hostinger.com\/co\/tutoriales\/comando-cat-linux","default":0},{"locale":"es-AR","link":"https:\/\/www.hostinger.com\/ar\/tutoriales\/comando-cat-linux","default":0},{"locale":"en-IN","link":"https:\/\/www.hostinger.com\/in\/tutorials\/linux-cat-command","default":0},{"locale":"en-CA","link":"https:\/\/www.hostinger.com\/ca\/tutorials\/linux-cat-command","default":0},{"locale":"en-AU","link":"https:\/\/www.hostinger.com\/au\/tutorials\/linux-cat-command","default":0},{"locale":"en-NG","link":"https:\/\/www.hostinger.com\/ng\/tutorials\/linux-cat-command","default":0}],"_links":{"self":[{"href":"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-json\/wp\/v2\/posts\/15648","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-json\/wp\/v2\/users\/449"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-json\/wp\/v2\/comments?post=15648"}],"version-history":[{"count":20,"href":"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-json\/wp\/v2\/posts\/15648\/revisions"}],"predecessor-version":[{"id":113545,"href":"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-json\/wp\/v2\/posts\/15648\/revisions\/113545"}],"wp:attachment":[{"href":"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-json\/wp\/v2\/media?parent=15648"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-json\/wp\/v2\/categories?post=15648"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-json\/wp\/v2\/tags?post=15648"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}