Linux Basic Text View command (cat,tac,rev,head,tail,more,less)

Source: Internet
Author: User
Tags control characters

Linux we always have to view the text of certain content, if we only because the view text to use VI into the file and added a lot of extra operation inconvenient. Here are some text-viewing commands that you should look after to help


Cat

cat-concatenate files and print on the standard output

Expression format:cat [OPTION] ... [FILE] ...

Common options:

-A: Show all control characters

-N: Displays the number of rows

-E: Display line terminator

Here are a few examples to illustrate the use of cat and its options

Experimental catalogue/test Text/TEST/CAT1/TEST/CAT2

[[email protected] test]# ll /test/total dosage  8- Rw-r--r--.  1 root root 43 8 Month    7 16:46 cat1-rw-r--r--.   1 root root 19 8 Month    7 16:46 cat2[[email protected] test ]# cat cat1    hi,everyonenow i will show how to  Use cat[[email protected] test]# cat -an cat1     1   hi,everyone$     2  now i will show how  to use cat$[[email protected] test]# cat -nE cat1 cat2      1  hi,everyone$     2  now I  Will show how to use cat$     3  this is  an example$ 

Cat can be followed by multiple files, common options can be combined with


TAC reverse display of cat, reversed by text

Tac-concatenate and print files in reverse

TAC [OPTION] ... [FILE] ...

[[Email protected] test]# TAC Cat1now I'll show how to use Cathi,everyone

TAC options are not commonly used and are therefore not introduced


Rev The contents of the file are displayed in reverse order.

Rev-reverse lines of a file or files

Rev [options] [file ...]

[Email protected] test]# rev cat1 Enoyreve,ihtac esu ot woh wohs lliw I won

Rev has no value to introduce options


Head

Head-output the first part of the files

Head [OPTION] ... [FILE] ...

Common options:

-C #: Shows the number of bytes before

-N #: Shows the number of rows before n can save

The first 10 lines of the file are displayed by the head file

[[email protected] test]# head-3 head 123456789012[[email protected] test]# head-c 3 head 123[[email protected] test]#


Tail

Tail-output the last part of the files

Tail [OPTION] ... [FILE] ...

Common options:

-C #: Number of bytes after display

-N #: Shows how many lines, N can save

-F: Trace display File New additions, common log monitoring

[[email protected] test]# tail-3 head 3451236[[email protected] test]# tail-c 5 head 236[[email protected] test]# tail -f/var/log/messagesaug 7 17:15:04 localhost dhclient[9668]: DHCPDISCOVER on eno16777728 to 255.255.255.255 port Inter Val One (xid=0x7773726a) 7 17:15:05 localhost networkmanager[916]: <warn> (eno16777728): DHCPv4 Request timed OU T.aug 7 17:15:05 localhost networkmanager[916]: <info> (eno16777728): DHCPV4 state changed unknown-timeout. .


More features: Automatic exit after turning the screen to the tail of the file

More-file perusal filter for CRT viewing

Expression format: More[options] file [...]

[[email protected] ~]# man /etc/init.d/functions...                 ;;            stop)                     s=$ "Stopping$prog  (via &NBSP;SYSTEMCTL):  "                   ;;           reload|try‐reload)                    s=$ "Reloading   $prog   configuration  (VIASYSTEMCTL):  "                  ;;          restart|try‐restart|con‐drestart)                   s=$ "Restarting  $prog   ( VIA&NBSP;SYSTEMCTL):  "                 ;;          esac manual page functions line  1  (Press h for help or q to quit)


Less

Less-opposite of more

In less, you can use the previous search function in man, and you can simply assume that less is a more enhanced version.

Less turns the screen to the end of the file and does not exit automatically.

[Email protected] ~]# less/etc/init.d/functions


This article is from "Zhang Fan-it's fantasy drifting" blog, please be sure to keep this source http://chawan.blog.51cto.com/9179874/1835392

Linux Basic Text View command (cat,tac,rev,head,tail,more,less)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.