2 Unit 6

Source: Internet
Author: User

# # #unit6. Shell Script Command # # #


# # #1. diff

Difffile file1# #比较两个文件的不同


Diff-C # #显示周围的行

Diff-u # #按照格式统一输出生成的补丁

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

??

Patch

Patchfile File.path# #打补丁

Patch-B # #备份原文件


# # #2. grep

grep key character file | directory # #在文件或目录中查找含有关键字的行


grep-I # #忽略大小写

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

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

grep-v # #反向过滤

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

grep- r keyword # #在目录中查找含有关键字的文件


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

Keyword $# #以关键字结尾


# # #3. Cut

Cut# #截取字符


Cut -D delimiter # #指定分隔符

Cut-F1,7 # #显示指定的列

CYT-C1-4 # #显示指定的字符


Show only IP addresses in ifconfig eth0

[Email protected] ~]# ifconfig eth0 | grep inet | grep inet6-v | Cut-d ""-F 10

[Email protected] ~]# ifconfig eth0 | grep inet | grep inet6-v | Awk-f "" ' {print $} '


# # #4. Sort

Sort# #排序


Sort-N # #纯数字排序

Sort-u # #去冗余 (Remove Duplicates)

Sort|uniq-c# #去除冗余并统计冗余次数

Sort-t # #指定分隔符

Sort-k # #指定列


# # #5. Uniq

Sort File | Uniq-c# #去掉冗余并统计冗余的次数

Sort File | uniq-d# #显示冗余行

Sort File | Uniq-u# #显示唯一行


# # #6. sed

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

Sed-e ' Strategy 1 '-e ' policy 2 ' file

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

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

sed xd# #屏蔽指定行

Sed xp# #复制指定行

Sed-n xp# #只显示指定行






This article is from the "12115084" blog, please be sure to keep this source http://12125084.blog.51cto.com/12115084/1871584

2 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.