Shell special symbol, Wc,uniq,tee_tr_split command

Source: Internet
Author: User

[[email protected] ~]# cut-d:-F 3/etc/passwd-d: delimiter-F plus number paragraph F is the first paragraph

0

1

2

[[email protected] ~]# cut-d:-F 3,4,5,6,7/etc/passwd can choose a few more paragraphs plus, you can

0:0:root:/root:/bin/bash

1:1:bin:/bin:/sbin/nologin

2:2:daemon:/sbin:/sbin/nologin

3:4:adm:/var/adm:/sbin/nologin

[[email protected] ~]# cut-c 10/etc/passwd-c is the first character C10 is the tenth character

0

:

2

[[email protected] ~]# cut-c 1-10/ETC/PASSWD first to tenth characters-C is the interval number

root:x:0:0

Bin:x:1:1:

Daemon:x:2



[[email protected] ~]# sort/etc/passwd default sort asma sort

aDm:x:3:4:adm:/var/adm:/sbin/nologin

aPache:x:48:48:apache:/var/www:/sbin/nologin

bIn:x:1:1:bin:/bin:/sbin/nologin

DAemon:x:2:2:daemon:/sbin:/sbin/nologin

[[email protected] ~]# sort-t:-k3/etc/passwd-t: Is the delimiter-K3 is the third paragraph sort

Root:x:0:0:root:/root:/bin/bash

Uucp:x:10:14:uucp:/var/spool/uucp:/sbin/nologin

Operator:x:11:0:operator:/root:/sbin/nologin

Bin:x:1:1:bin:/bin:/sbin/nologin

[[email protected] ~]# sort-t:-k3-n/etc/passwd-n Sort by number can also-K 3,6 interval value

Root:x:0: 0:root:/root:/bin/bash

Bin:x:1: 1:bin:/bin:/sbin/nologin

Daemon:x:2: 2:daemon:/sbin:/sbin/nologin

ADM:X:3: 4:adm:/var/adm:/sbin/nologin

[Email protected] ~]# sort-t:-k3,5-n-r/etc/passwd-r is reverse order

Yun:x:500:500::/home/yun:/bin/bash

SASLAUTH:X:499:76:SASLAUTHD User:/var/empty/saslauth

Bin:x:1:1:bin:/bin:/sbin/nologin

Root:x:0:0:root:/root:/bin/bash

[Email protected] ~]# sort-t:-K 3,5-n-r-u/etc/passwd-u is to repeat the meaning

Sort-un 2.txt can also be used this way


[[email protected] ~]# uniq-c 2.txt plus option-C list Duplicates

1 1

1 2

1 3

2 4

1 5

2 6

1 7

2 8

2 9

[[email protected] ~]# sort 2.txt |uniq-c order in go to repeat

1 1

1 10

1 12

1 1212

1 12166

1 2

1 3

2 4

1 5

2 6

1 7

2 8

2 9

[[email protected] ~]# echo "1111111" |tee 1.txt Tee Usage

1111111

[Email protected] ~]# echo "1111111" |tee 1.txt

1111111

[email protected] ~]# cat 1.txt

1111111


[[email protected] ~]# ls *.txt |tr ' A-Z ' A-z '. txt becomes the capital letter name into the uppercase TR replacement character

1.TXT

2.TXT

C.TXT

M.TXT

Z.TXT

[[email protected] ~]# echo $ "JKSADHASJKDH" |tr ' j ' E ' replace uppercase and lowercase characters

$ eksadhasekdh

[[email protected] ~]# echo "JKSADHASJKDH" |tr ' j ' E '

Eksadhasekdh

[[email protected] ~]# echo "JKSADHASJKDH" |tr ' A-Z ' A-z ' global replacement can also be reduced to a range of ' a-f '

Jksadhasjkdh

Split-Cut Log

[[email protected] ~]# Split-l How many lines of anaconda-ks.cfg-l

[[email protected] ~]# ls

C.txt link xaa xab

12.tar install.log m.txt xac

1.txt install.log.syslog wps xad

[[email protected] ~]# DU-SB anaconda-ks.cfg View Size

1028 Anaconda-ks.cfg

[[email protected] ~]# split-b anaconda-ks.cfg-b 100b cut

[Email protected] ~]# LS-LH xa*

-rw-r--r--1 root root 100 October 07:53 Xaa

-rw-r--r--1 root root 100 October 07:53 Xab

-rw-r--r--1 root root 100 October 07:53 xac

-rw-r--r--1 root root 100 October 07:53 xad

-rw-r--r--1 root root 100 October 07:53 xae

-rw-r--r--1 root root 100 October 07:53 Xaf

-rw-r--r--1 root root 100 October 07:53 xag

-rw-r--r--1 root root 100 October 07:53 Xah

-rw-r--r--1 root root 100 October 07:53 Xai

-rw-r--r--1 root root 100 October 07:53 Xaj

-rw-r--r--1 root root 28 October 07:53 Xak

[[email protected] ~]# split-b anaconda-ks.cfg new_ change name New

[[email protected] ~]# ls

Link New_ai xaf

12.tar m.txt New_aj Xag

1.txt New_aa New_ak Xah

2.txt New_ab wps Xai

Anaconda-ks.cfg New_ac Wps.zip Xaj


&& and | | Or

[[email protected] ~]# ls 1.txt && ls 2.txt capable of executing the first before executing the second

1.txt

2.txt

[[email protected] ~]# ls 1.txt && ls 20.txt previous command execution will execute subsequent command

1.txt

LS: Unable to access 20.txt: No file or directory

[[email protected] ~]# ls 10.txt && ls 2.txt If the previous command did not execute successfully it no longer executes the following command

LS: Unable to access 10.txt: No file or directory

[[email protected] ~]# ls 1.txt | | LS 2.txt

1.txt

[[email protected] ~]# ls 10.txt | | LS 20.txt

LS: Unable to access 10.txt: No file or directory

LS: Unable to access 20.txt: No file or directory

[[email protected] ~]# ls 10.txt | | LS 2.txt

LS: Unable to access 10.txt: No file or directory

2.txt

&& the command on the left executes successfully before executing the command on the right

|| The command on the left is unsuccessful to execute the command on the right.

; If the command on the left succeeds or not, the command will execute


This article is from the "11325852" blog, please be sure to keep this source http://11335852.blog.51cto.com/11325852/1982959

Shell special symbol, Wc,uniq,tee_tr_split command

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.