Skip to content
Technology News Information & Jobs

Technology News Information & Jobs

Ubuntu Tutorials, Ubuntu How To , Linux Tips, Tech Jobs

  • Work with US
  • Search Jobs
  • Post a Job
  • Contact Us
  • Ubuntu
    • Ubuntu 18.04
  • Ubuntu 20.04
  • Ubuntu 22.04
  • Themes
  • Linux
  • Laptops
  • Tutorials
  • Job Dashboard
  • Toggle search form
Basic Cat Command Examples In Linux

15 Basic Cat Command Examples In Linux

Posted on March 15, 2023 By admin No Comments on 15 Basic Cat Command Examples In Linux

15 Basic Cat Command Examples In Linux

The cat is short for the “concatenate“ command. It is mostly used in file management tasks like creating single or multiple files, viewing the content of a file, concatenating files, etc.

15 Basic Cat Command Examples In Linux

1. Cat Command To Display The Content Of  A File:

Run the following cat command that displays the contents of a file. In the following command, you can see the content of the file named filename.txt

Cat filename.txt

2. Cat Command To Display The Content Of  Two Files:

Run the following cat command that displays the contents of two files.

cat file1.txt file2.txt

3. Cat Command To Create A New File:

This command creates a new file named “file_name.txt” and allows you to enter text into it.

cat > file_name.txt

Press Ctrl+D to save and exit.

4. Cat Command To Appends The Contents Of One File To Another File:

The following cat command appends the contents of “file_name.txt” to the end of “file2_name.txt”.

cat file_name.txt >> file2_name.txt

5. Cat Command To Display The Contents Of One File That Matches The Search Term:

Run the following cat command to display the contents of “filename.txt” that match the search term “search_term”.

cat filename.txt | grep "search_term"

6. Cat Command To Display The Contents Of File With Line Numbers:

This cat command displays the contents of “filename.txt” with line numbers.

cat -n filename.txt

7. Cat Command To Display The Contents Of the File for nonblank lines.

The following cat command displays the contents of “filename.txt” with line numbers, but only for non-blank lines.

cat -b filename.txt

8. Cat Command To Display The Contents Of File for with multiple blank lines compressed into a single blank line

Run the following cat command in your terminal to display the contents of “filename.txt” with multiple blank lines compressed into a single blank line.

cat -s filename.txt

9. Cat Command To Display The Contents Of File with tabs represented as ^I.

Open your terminal and run the following command to display the contents of “filename.txt” with tabs represented as ^I.

cat -T filename.txt

10. Cat Command To Enter Commands via the terminal to the file

Run the following cat command to enter commands into the terminal that will be processed as if they were entered from a file named “file.txt”.

cat < filename.txt

11. Cat Command To displays the contents of the file with a $ symbol at the end of each line.

Run the following cat command that displays the contents of “filename.txt” with a $ symbol at the end of each line.

READ More Relevant Stuff:  200+ Free Linux Ebooks Collection For Lifetime

cat -E filename.txt

12. Cat Command To displays the contents of all files in the current directory that start with “file” and end with “.txt”.

Run the following command to display the contents of all files in the current directory that start with “filename” and end with “.txt”.

cat filename*.txt

13. Cat Command To displays the contents of file with non-printable characters represented as ^X.

This following cat command displays the contents of “filename.txt” with non-printable characters represented as ^X.

cat -v filename.txt

14. Cat Command To empties the contents of file.

Run the following cat  command to empty the contents of the file.

cat /dev/null > filename.txt:

15. Cat Command To display the version of the cat command.

The following cat command displays the version of the cat command.

cat --version
How To Ubuntu, Linux, Linux Commands Tags:linux, Linux command

Post navigation

Previous Post: Fedora Linux 38 Beta Released
Next Post: How To Transfer Existing Steam Game From One PC To Another Over A LAN

Related Posts

Remove Files And Directories In Linux From Terminal Remove Files And Directories In Linux From Terminal Linux Commands
Best Linux Gaming Distros In 2022 For Gamers Best Linux Gaming Distros In 2022 For Gamers Linux
Mozilla Firefox 76.0 For Ubuntu 20.04 LTS Firefox 76 Released With Security Enhancement Linux
Kali Linux 2021.3 Released, Download ISO Now Kali Linux 2021.3 Released, Download ISO Now Linux
Linux Mint 20.2 Now Available Linux Mint 20.2 Now Available Linux
Linux Commands To Remove Files And Directories Linux Commands To Remove Files And Directories Linux

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts

  • New Job Search October 10, 2025
  • How To Enable Hibernate in Ubuntu 22.04 LTS May 20, 2024
  • Popular Ubuntu Games: Top 5 Games To Play March 17, 2024
  • WordPress | Your site doesn’t include support for the “generateblocks/container” block GenerateBlocks Plugin February 11, 2024
  • Ubuntu Autoremove Command Debian Autoremove Command February 10, 2024
  • How To Mount Windows 11 Shares on Debian Linux December 7, 2023
  • Anonymous Browsing 101: A Deep Dive Into Residential Proxies November 20, 2023
  • How To Correctly Install Uninstall Linux Ubuntu Nvidia Drivers Fast October 31, 2023
  • Ethical Web Design: The Dos and Don’ts October 28, 2023
  • Understanding the Role of Security Operations Center October 25, 2023
  • The Positive Effects of AI Tools and Online Services on Students Successful Essay-Writing Skills October 3, 2023

Categories

  • Android
  • Apple
  • Blogs
  • Debian
  • Fix
  • Gadgets
  • Game
  • Google
  • How To Ubuntu
  • Internet
  • Laptops
  • Linux
  • Linux Commands
  • Linux Game
  • Linux Mint
  • News
  • Operating Systems
  • Security
  • Technology
  • Themes
  • Tools
  • Tutorials
  • Ubuntu
  • ubuntu 18.04
  • Ubuntu 20.04
  • Ubuntu 22.04
  • Windows 11
  • Wordpress
itsubuntu.com is an Equal Opportunity Employer. For Advertisement, Jobs, Guest posts, and any other thoughts, email us at info@itsubuntu.com
  • Remote Writer/Journalist Internship – Poverty Advocacy

    • Vermillion, SD
    • The Borgen Project
    • Internship
  • Reporter/Writer, Justice, CNN

    • Washington DC
    • Warner Bros Discovery
    • Full Time
  • Technical Writer Level II

    • Arlington, OH
    • ATTAINX INC
    • Full Time
  • Government and Infrastructure – Business Transformation – Technical Writer – Staff

    • California
    • EY
    • Full Time
  • Service Writer

    • Georgetown, KY
    • Meade Tractor
    • Full Time
  • Estimate Writer aka Friendly Outgoing

    • Griffin, GA
    • Cambri Ventures, Inc
    • Full Time
  • Remote Grant Writer for Arts Education Impact

    • Hamden, CT
    • Arts for Schools Inc formerly Arts in CT
    • Full Time
  • Grant Writer

    • United States
    • JerseySTEM
    • Full Time

Copyright © 2026 Technology News Information & Jobs.

Powered by PressBook Grid Blogs theme