How to use Linux cat, less, more commands

Today, my colleague showed me a picture.

He used this picture to illustrate the less, more and cat commands.

This is the picture above.

The explanation of the cat command is ok, but the less and more are obviously wrong.

More powerful than cat, providing paging display function, less powerful than more, providing page turning, jump, find and other commands.

cat

The cat command displays the contents of the entire file at one time.

It can also display multiple files together.

It is often used in conjunction with the redirection symbol.

It is suitable for cases where the content of the file is small.

NAME
     cat -- concatenate and print files

SYNOPSIS
     cat [-benstuv] [file ...]

Cat Example

Print file content

➜ cat test.txt

Concatenate files

➜ cat test1.txt test2.txt > test3.txt

more

more is an old utility.

When the text passed to it is too large to fit on one screen, it pages it.

Can scroll down but not scroll up.

Some systems hardlink more to less, as mac system.

➜ man less
# ➜ man more
NAME
       less - opposite of more

SYNOPSIS
       less -?
       less --help
       less -V
       less --version
       less [-[+]aABcCdeEfFgGiIJKLmMnNqQrRsSuUVwWX~]
            [-b space] [-h lines] [-j line] [-k keyfile]
            [-{oO} logfile] [-p pattern] [-P prompt] [-t tag]
            [-T tagsfile] [-x tab,...] [-y lines] [-[z] lines]
            [-# shift] [+[+]cmd] [--] [filename]...
       (See the OPTIONS section for alternate option syntax with long option names.)


DESCRIPTION
       Less  is a program similar to more (1), but which allows backward movement in the file as well as forward movement.  Also, less does not have to read the entire input file before starting, so with large input files it starts up faster than text editors like vi (1).  Less uses  termcap  (or  terminfo  on  some systems), so it can run on a variety of terminals.  There is even limited support for hardcopy terminals.  (On a hardcopy terminal, lines which should be printed at the top of the screen are prefixed with a caret.)

       Commands are based on both more and vi.  Commands may be preceded by a decimal number, called N in the descriptions  below.   The  number  is used by some commands, as indicated.

man less and man more is the same result.

less

Less commands are based on both more and vi, an open source project.

Can scroll down and up, search.

More/Less Example

➜ more test1.txt
➜ less test1.txt
# Mac less = more

So, if you use the above picture to explain the less and more commands, it is obviously wrong.

Add a Comment

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