Linux 150 command view files and content processing commands more split file diff paste WC Dps2unix

Source: Internet
Author: User
Tags diff file diff using git

More commands

Using the more command to display the more/var/log/boot.log-20171129 file, you can see that the system is displayed full screen when the pause, use a space to page, use the Q key to exit.

Split

The split command splits a large file into small files that sometimes need to be split into smaller pieces, such as for readability, log generation, and so on.

-B: The value is the size of each output file, in bytes.

-D: Use a number as a suffix.

-A: Defines the number of digits

Test

[Email protected]]# dd If=/dev/zero bs=100k count=1 of=data #生成一个大小为100k的文件

[[Email protected]]# split-b 10k Data

[Email protected]]# ls

Data xab xad xaf Xah Xaj

nginx.conf xaa xac xae xag Xai

Files are split into smaller chunks

[[Email protected]]# split-b 10k data-d-a 2 SS

[Email protected]]# ls

Data oldboy4 ss01 ss03 ss05 ss07 ss09

nginx.conf ss00 ss02 ss04 ss06 ss08

File

The file command is used to probe the type of a given document

diff Vimdiff

Compare commands, and compare the contents of the file.

Paste

-S can merge multiple rows of data from one file into a single row for display

Paste will combine each file in a column-by-column manner.

[email protected] ~]# cat >>a.txt<<EOF>oldboy1>Oldboy2>Oldboy3>Eof[[email protected]~]# Cat >>b.txt<<EOF>Oldboy4>oldboy5>Oldboy6>Eof[[email protected]~]# Cat >>c.txt<<EOF>Oldboy7>Oldboy8>Oldboy9>Eof[[email protected]~]# paste a.txt b.txt c.txtoldboy1 oldboy4 oldboy7oldboy2 oldboy5 oldboy8oldboy3 oldboy6 Oldboy9[[ema Il protected]~]# Paste-s a.txtoldboy1 oldboy2 oldboy3
Wc

WC statistics Yte Number, word count, or number of columns

-C or--bytes or--chars shows only the number of bytes.

-L or--lines displays only the number of rows.

-W or--words displays only the number of words

-L statistic Word has several letters

[[email protected] ~]# cat a.txt |WC-l4~~]# cat a.txt |WC-l3  ~]# cat A.txt |WC-c~]# cat a.txt |WC-w3~]# Cat A.txt |WC-L7~]# cat A.txtoldboy1oldboy2oldboy3

Dos2unix

When using Git, when you encounter git converting Unix newline characters to Windows newline characters, you need to use the Dos2unix command to convert the files to UNIX format.

Sort

Pipe Sorting Sort can be ordered for the contents of a text file in the unit of behavior.

- u option It is simple to remove duplicate rows in the output line.

Sort of the - R Options Sort The default sort is ascending, and if you want to change to a descending order, add a - R it's done.

Sort of the - o Options

because Sort The default is to output the results to standard output, so a redirect is required to write the results to the file, as sort filename > NewFile .

-U

[

[Email protected] ~~~]# Sort-u seq.txtapplebananaorangepear

-R

[Email protected] ~]# sort Num.txt 1 2 3 4 5 6 7 8  ~]# Sort-R num.txt876543 2 1

-O

[email protected] ~]# sort-r num.txt-~]# cat num.txt87654  321

Uniq

Uniq to check for recurring rows and columns in a text file

[Email protected] ~]# cat Seq.txtbananaappleorangepearpearpearpearpear

-C or--count displays the number of occurrences of the row next to each column.

[[email protected] ~]# Uniq-C seq.txt1  banana1  Apple1  Orange5 Pear

-D or--repeated displays only the rows that appear repeatedly.

[Email protected] ~]# Uniq-D seq.txtpear

Linux 150 command view files and content processing commands more split file diff paste WC Dps2unix

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.