We are committed to provide service 24 X 7

Deals, Shopping, Training, Tools

How to Use Cat, Tac, More, Less – Linux Commands

How to Use Cat, Tac, More, Less – Linux Commands. These basic commands are most effective when used in the correct way. These commands are used on a daily basis for every Linux DevOPS.

In this guide you are going to learn how to use these simple linux commands with examples.

CAT Command

Cat command is a short form for Concatenate, which is one of the most used Linux commands.

Output Contents

This command reads the file and outputs all content to your terminal. The basic syntax in shown below.

cat filename
Output
Contents of your file...
...
...

Output Contents of Multiple Files

You can also use this command to output all contents of multiple files.

cat filename1 filename2 filename3
Output
Contents of your filename1
Contents of your filename3
Contents of your filename3

Merge Multiple Files to Single File

You can also merge the contents of all files to a single file using the > operator.

cat filename1 filename2 filename3 > new-merged-file.txt

Append to Existing File

You can also append the content of a file to an existing file.

cat filename > existing-file.txt

Other Options for CAT Linux Command

There are also other options for CAT command, some of them are listed below.

  • -n: Display the content including the empty lines.
  • -b: Display numbered output of non-empty lines.

TAC Command

Tac command is an exact reversal of cat command. This Linux command is mainly useful to output the latest content of a file starting from the bottom line to the first line.

cat filename
Output
Contents of your file...
Last line
...
...
First line

MORE Command

more command is one of the oldest Linux command which is mainly used to output the content of the file page by page. If your file is too big you can use the more command to output the contents.

more filename

You can use the - operator to tell the command to output n number of lines in a page.

Outputs 10 lines per page
more -10 filename

You can use the + operator to tell the command to start output the content from a specific line.

Start output the content from 10th line
more +10 filename

LESS Command

The less command is one of the flexible Linux command which is similar to more command but have more advantages. This command outputs the content in a file editor and allows you to move forward and backward, go to end or start immediately.

less filename

Prepare yourself for a role working as an Information Technology Professional with Linux operating system

Conclusion

Now you have learned about cat, tac, more and less Linux commands and how to use them.

Thanks for your time. If you face any problem or any feedback, please leave a comment below.

14
854.772,70