LINUX-12 Basic command of Cat,more,head, tail, Tr,od,wc,cut,diff

Source: Internet
Author: User
Tags diff

1. Cat commands for viewing plain text files (shorter), format: "cat[options [File]"

View text files

Cat file name
Cat parameters
Parameters Role
-N Show line Numbers
-B Display line numbers (not including spaces)
-A Displays invisible symbols, such as spaces, tab

2. The more command is used to view plain text files (longer) format: "more[Options" File "

View text files

[[email protected] etc]# more   file name
More parameters
Parameters Role
-Digital Number of pre-displayed rows (default is one page)
-D Display prompt statement and error message

3. Head command to view the first n rows of text

View the first 20 lines of text

Head Ten file names

Head command
Parameters Role
-N 10 Show 10 rows
-n-10 Normal output without showing the last 10 rows

  

4. Tail view Plain text documents with the following n-line format: "tail [options] [file]"

View the following 20 lines of the text file:

Tail  -  Filename
Tail parameters
Parameters Role
-N 10 Show back 10 rows
-F Refresh the displayed content continuously

5. The TR command is used to convert characters in a text file in the format: "tr[original character [target character]"

Cat tr. Tex | TR [A-z] [A-z]

6. The OD command is used for viewing files in special formats. Format as "od[options [File]"

7. The WC command is used to count the number of lines, words, and bytes of the text, formatted as: "wc[parameter] text"

WC command
Parameters Role
-L Number of rows displayed

-W

Show only the number of words
-C Show only bytes

View the number of users in the current system

WC -l/etc/passwd

8. Cut

9. The diff command is used to compare multiple file literals in the format: "diff[parameter] file"

Diff parameter
Parameters Role
-B Ignore differences caused by whitespace
-B Ignore differences caused by whitespace
-brief OR-Q Report only if there is a discrepancy
-C Use context output format

Compare the differences between 2 files

[Email protected] etc]#  diff Diff_a.txt  diff_b.txt

Show only the comparison results, same or different

diff --brief Diff_a.txt diff_b.txt

LINUX-12 Basic command of Cat,more,head, tail, Tr,od,wc,cut,diff

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.