Two: Unit 6

Source: Internet
Author: User


1.diff

diff file File1 #比较两个文件的不同

- C #显示上下周围的行

- u #按照一定格式统一输出补丁

- R #比较两个目录中文件的不同

Patch file File.path #打补丁

- b # #备份源文件

2.grep

grep Key Characters File | directory # #在文件或者目录中查找含有关键字的行

grep - I. # #忽略大小写

- N # #显示关键字所在行

- C # #显示过滤结果的个数

- v # #反向过滤

- E "keyword 1| keyword 2" # #过滤多个关键字

- R Catalogue # #在目录中查找含有关键字的文件

Note: ^ Keywords # #以关键字开头

keyword $ # #以关键字结尾

3.cut

Cut # #截取字符

cut-d delimiter # #指定分隔符

cut-f 1.7 # #显示指定的列

cut-c 1-4 # #显示第一个到第四个字符

4.sort # #排序

- N # #纯数字排序

- u # #去冗余

|uniq-c # #去冗余并统计冗余个数

- T # #指定分隔符

- k # #指定列

5.uniq

sort-n file |uniq-c # #去冗余并统计冗余次数

- D # #显示冗余行

- u # #显示唯一行

6.sed

Sed ' s/original character/replacement character/g ' file

Sed-e ' Strategy 1 '-e ' strategy 2 '

sed-i file # #把转换后的内容输入到指定文件

sed ' 3,5s/original character/replacement character/g ' # #3-5 line replacement

sed ' 3s/original character/replacement character/g ' # #第3行替换

sed xd # #屏蔽指定行

sed xp # #复制指定行

sed-n XP # #只显示指定行

7.awk

awk ' condition type {action 1} condition type {action 2} ... ' filename

Awk primarily handles data in the fields of each row, and the default field delimiter is the Space or TAB key

awk numeric operator

++ -- # #增加与减少 (front or rear)

^ **                   # #指数 (right associative)

! +- # #非, unary Plus, unary minus

* / %                  # #乘, except, remainder

+ -                  # #加, minus

< <= == != > >= # #比较

&& # #逻辑AND

|| # #逻辑OR

? : # #三元条件式

= += -= *= /= %= ^= **=             # #赋值 (right associative)

awk built-in scalar variables

FILENAME # #当前输入文件的名称

FNR # #当前输入文件的记录数

FS # #字段分隔符 (regular expression)

NF # #当前记录的字段数

NR # Number of records #在工作中 (Job)

OFS # #输出字段分隔符

ORS # #输出记录分隔符

RS # #输入记录分隔符


This article from "12110289" blog, declined reprint!

Two: Unit 6

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.