Shell special symbol, cut command, sort_wc_uniq command, tee_tr_split command, Shell special symbol

Source: Internet
Author: User

Shell Special Symbols

* Any of any characters

[[email protected] ~]# ls *.txt

1.txt 23.txt 2.txt David.txt

? Any one character

[email protected] ~]# ls?. Txt

1.txt 2.txt

# comment Characters

[[email protected] ~]# #echo ' OK '

\ de-Semantic characters

[Email protected] ~]# echo-e ' 123\n456\n789\t0000 '

123

55W

7890000

| Pipe character

[email protected] ~]# cat 2.txt|wc-l

2


Cut command

-b Specifies the number of bytes

-D delimiter

-F Specify segment number

-c Specifies the number of characters, if the Chinese character equals 3 bytes c=3b; English c=b

[email protected] ~]# cat 2.txt

I am Linux my QQ 1234567


[email protected] ~]# cat 2.txt|cut-b 1,2,3,4

I am

[email protected] ~]# cat 2.txt|cut-c 1,2,3,4

I am


The difference between Chinese and English

[email protected] ~]# cat 1.txt

I'm a Linux

[email protected] ~]# Cat 1.txt|cut-c 1

I

[email protected] ~]# cat 1.txt|cut-b

I

Example 2: Print out Linux my

[email protected] ~]# cat 2.txt

I am Linux my QQ 1234567


[email protected] ~]# cat 2.txt|cut-d "-f 3,4

Linux my


Sort_wc_uniq command

-N Sort Ascending by numeric value

-R Reverse

-U excludes duplicate rows


[Email protected] ~]# sort-n 2.txt

0

0

0

1

1

2

2

3

4

45

56

56

66

87

687

-R: Reverse

[Email protected] ~]# sort-r 2.txt

87

66

56

56

45

4

Go weight:

[Email protected] ~]# Sort-un 2.txt

0

1

2

3

4

45

56

66

87

-T is represented by: is a delimiter;-k3 is sorted by 3rd paragraph

[Email protected] ~]# sort-n-T:-k3 3.txt


pear:90:2.3

apple:10:2.5

orange:20:3.4

banana:30:5.5


Wc-l number of statistics file lines

Wc-c Statistic character Count

Wc-w statistics of words


Uniq

Uniq-d: Show only recurring rows

Uniq-u: Show rows that do not recur

UNIQ-C: Number of calculations


[email protected] ~]# cat Test.log

Https://www.taobao.com/1.html

Https://www.taobao.com/2.html

Https://www.taobao.com/3.html

Https://www.taobao.com/2.html

Https://www.baidu.com/inyydex.html

Https://www.baidu.com/in.html

Https://www.baidu.com/index.html

Https://jusjuu.ia/jsw/zdnst/index.html


[[email protected] ~]# awk-f ' [:/]+ ' {print $} ' Test.log |uniq

Www.taobao.com

Www.baidu.com

Jusjuu.ia

[[email protected] ~]# awk-f ' [:/]+ ' {print $} ' Test.log |uniq-c

4 www.taobao.com

3 www.baidu.com

1 Jusjuu.ia

[[email protected] ~]# awk-f ' [:/]+ ' {print $} ' Test.log |uniq-d

Www.taobao.com

Www.baidu.com


Tee_tr_split command

Tree

Tee and > similar, redirect while still on screen display


Tr

Replace character

[Email protected] ~]# echo "HELLO World" | Tr ' A-Z ' A-Z

-D: Delete

[[email protected] ~]# echo "HELLO 123 WORLD12 12" | tr-d [0-9]

HELLO World


[Email protected] ~]# echo "hello:123 world:12" | Tr-s ":" "="

Hello=123 world=12


Split

Cutting

-B Size (default unit byte)

-L Number of rows


This article is from the "Discover new things" blog, make sure to keep this source http://shenj.blog.51cto.com/5802843/1978798

Shell special symbol, cut command, sort_wc_uniq command, tee_tr_split command, Shell special symbol

Related Article

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.