Shell special symbols, cut_sort_wc_uniq commands, and Tee_tr_split commands

Source: Internet
Author: User
Tags sorts

Shell Special Symbols

    • * Any of any characters

    • ? Any one character

    • # comment Characters

    • \ de-Semantic characters

    • | Pipe character

    • $ variable prefix,!$ combination, regular inside means end of line

    • ; Multiple commands written to one line, separated by semicolons

    • ~ User home directory, followed by regular expression to indicate match

    • & put the command behind the command and throw it backstage.

    • > >> 2> 2>> &>

    • [] One of the specified characters, [0-9],[A-ZA-Z],[ABC]

    • || And &&, used between commands

Cut_sort_wc_uniq command

Cut Delimited

Options

-D delimiter

-F Specify segment number

[Email protected] ~]# cat/etc/passwd |head-2 |cut-d ":"-f 1rootbin[[email protected] ~]# cat/etc/passwd |head-2 |CU T-d ":"-f 1,2root:xbin:x[[email protected] ~]# cat/etc/passwd |head-2 |cut-d ":"-F 1-3root:x:0bin:x:1

-c Specifies the number of characters

[Email protected] ~]# cat/etc/passwd |head-2root:x:0:0:root:/root:/bin/bashbin:x:1:1:bin:/bin:/sbin/nologin[[ Email protected] ~]# cat/etc/passwd |head-2 |cut-c 4t:

Sort sorts

Instance:

650) this.width=650; "Src=" Https://s2.51cto.com/oss/201711/18/dbfc28568903c4c798a6ee774b83059d.png-wh_500x0-wm_3 -wmp_4-s_3849777129.png "title=" Qq20171116232935.png "alt=" Dbfc28568903c4c798a6ee774b83059d.png-wh_ "/>

Options

-N Sorts by numbers: letters and special symbols are labeled 0

-R Reverse Order

-T delimiter-kn1/-kn1,n2

Wc

Options

-L count rows

[[email protected] a]# cat 1.txt |head-1root:x:0:0:root:/root:/bin/bash[[email protected] a]# cat 1.txt |head-1 |WC-L1

-M statistic character number

[[email protected] a]# cat 1.txt |head-1 |wc-m32[[email protected] a]# cat 1.txt |head-1 |cat-aroot:x:0:0:root:/root:/ bin/bash$

-W statistic: delimiter as a white-space character

[[email protected] a]# echo ' aaa bbb,wwww 222211$a ' |WC-W3

Uniq to repeat

# Uniq 1.txt need to sort and then go back to Weight # sort 1.txt |uniq[[email protected] a]# echo ' 2222> 1111> 2222> 1111> 1bx> 2bx>  1bx ' |sort |uniq11111bx22222bx# uniq-c count rows//sort 1.txt |uniq-c[[email protected] a]# echo ' 2221112221BX2BX1BX ' |sort |uniq-c 1 111 2 1bx 2 222 1 2BX

Tee_tr_split command

Tee and > similar, redirect at the same time also on the screen display-A//Append

[Email protected] a]# echo ' 2222 ' |tee 2.txt2222[[email protected] a]# cat 2.txt2222[[email protected] a]# echo ' 2222 ' |te E-a 2.txt2222[[email protected] a]# cat 2.txt22222222

TR replacement character, tr ' a ' B ', case replacement TR ' [A-z] ' [A-z] '

[[email protected] a]# echo ' A ' |tr ' a ' a ' a

Split Cut,-B size (default unit byte),-L line number

[[email protected] a]# du-sh 1.txt4.0k1.txt[[email protected] a]# split-b 1.txt[[email protected] a]# ls1.txt XAA Xab xac xad xae[[email protected] a]# du-sh24k. [[email protected] a]# ls-l total usage 24-rw-r--r--. 1 root root 461 November 10:34 1.txt-rw-r--r--. 1 root root 100 November 11:45 xaa-rw-r--r--. 1 root root 100 November 11:45 xab-rw-r--r--. 1 root root 100 November 11:45 xac-rw-r--r--. 1 root root 100 November 11:45 xad


This article is from the "Travels of Taoyuan" blog, please make sure to keep this source http://3622288.blog.51cto.com/9153892/1982951

Shell Special symbols, cut_sort_wc_uniq commands, and Tee_tr_split commands

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.