Shell script commands

Source: Internet
Author: User
Tags diff

#######################

# # # #6. Shell script Command # # #

#######################

# # # #1. diff####

diff file File1 # # compare two different files

650) this.width=650; "Src=" Http://s1.51cto.com/wyfs02/M02/89/F2/wKiom1gibD_g2onYAAAimgMkcyM950.png-wh_500x0-wm_3 -wmp_4-s_2896849048.png "title=" image 1.png "alt=" wkiom1gibd_g2onyaaaimgmkcym950.png-wh_50 "/>

650) this.width=650; "Src=" Http://s1.51cto.com/wyfs02/M02/89/EE/wKioL1gibEvwY5WJAAEb9iAKQX0196.png-wh_500x0-wm_3 -wmp_4-s_151034984.png "title=" image 2.png "alt=" wkiol1gibevwy5wjaaeb9iakqx0196.png-wh_50 "/>

- C # # Displays the surrounding rows

- u # # generate patches in one format unified output

- R # # Compare the different files in two directories

650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M02/89/EE/wKioL1gibFbwi7ToAABryDhS8Kg760.png-wh_500x0-wm_3 -wmp_4-s_1035295527.png "title=" image 3.png "alt=" wkiol1gibfbwi7toaabrydhs8kg760.png-wh_50 "/>

Patch file File.path # # hit patch

650) this.width=650; "Src=" Http://s5.51cto.com/wyfs02/M00/89/F2/wKiom1gibGGyDVefAAB3SRsvMOE469.png-wh_500x0-wm_3 -wmp_4-s_3928241679.png "title=" image 4.png "alt=" wkiom1gibggydvefaab3srsvmoe469.png-wh_50 "/>

- b # # back up the original file

650) this.width=650; "Src=" Http://s5.51cto.com/wyfs02/M00/89/F2/wKiom1gibG2RcPVrAADRVYz8tr0475.png-wh_500x0-wm_3 -wmp_4-s_2180580962.png "title=" image 5.png "alt=" wkiom1gibg2rcpvraadrvyz8tr0475.png-wh_50 "/>

# # # #2. grep####

grep Key Characters File | Catalogue # # Find rows in a file or directory that contain keywords

650) this.width=650; "Src=" Http://s2.51cto.com/wyfs02/M00/89/EE/wKioL1gibHuzxVNzAAGW-WrDUhI827.png-wh_500x0-wm_3 -wmp_4-s_1867881759.png "title=" image 6.png "alt=" wkiol1gibhuzxvnzaagw-wrduhi827.png-wh_50 "/>

grep - I. # # Ignore case

650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M00/89/EE/wKioL1gibIfQRTWlAABpDRcF5Sw922.png-wh_500x0-wm_3 -wmp_4-s_1626390714.png "title=" image 7.png "alt=" wkiol1gibifqrtwlaabpdrcf5sw922.png-wh_50 "/>

- N # # Displays the line of keywords

650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M01/89/F2/wKiom1gibJGSZ0NVAABXieNtaUI347.png-wh_500x0-wm_3 -wmp_4-s_3347181281.png "title=" image 8.png "alt=" wkiom1gibjgsz0nvaabxientaui347.png-wh_50 "/>

- C # # shows the number of filtered results

- v # # Reverse filter

650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M01/89/F2/wKiom1gibJ3TyaQlAAEYkeqLPfc698.png-wh_500x0-wm_3 -wmp_4-s_738159779.png "title=" image 9.png "alt=" wkiom1gibj3tyaqlaaeykeqlpfc698.png-wh_50 "/>

- E " keyword 1| Key Words 2 " # # filter multiple keywords

- R Catalogue # # Find files with keywords in the directory

Note: ^ keywords # # starts with a keyword

keyword $ # # ends with a keyword

650) this.width=650; "Src=" Http://s5.51cto.com/wyfs02/M01/89/EE/wKioL1gibKmxj517AABQyyIN-D8125.png-wh_500x0-wm_3 -wmp_4-s_1474144199.png "title=" image 10.png "alt=" wkiol1gibkmxj517aabqyyin-d8125.png-wh_50 "/>

# # # #3. cut####

Cut # # intercept characters

cut-d Separators # # Specify delimiter

cut-f 1,7 # # Displays the specified columns

cut-c 1-4 # # Displays the specified characters

650) this.width=650; "Src=" Http://s5.51cto.com/wyfs02/M02/89/EE/wKioL1gibMqB_eFcAADVYjEp3wA528.png-wh_500x0-wm_3 -wmp_4-s_215096693.png "title=" image 11.png "alt=" wkiol1gibmqb_efcaadvyjep3wa528.png-wh_50 "/>

Cut-c 1,4

650) this.width=650; "Src=" Http://s2.51cto.com/wyfs02/M02/89/F2/wKiom1gibOSxVXyYAAAxVm5s_po735.png-wh_500x0-wm_3 -wmp_4-s_2159965451.png "title=" image 12.png "alt=" wkiom1gibosxvxyyaaaxvm5s_po735.png-wh_50 "/>

# # # #4. sort#### # # Sort

Sort

- N # # Pure digit sort

- u # # go redundant

|uniq-c # # Remove redundancy and count redundancy times

- T # # Specify delimiter

- k # # Specify columns

650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M00/89/EE/wKioL1gibVWCwElmAABoJ5VVuu4767.png-wh_500x0-wm_3 -wmp_4-s_583431554.png "title=" image 14.png "alt=" Wkiol1gibvwcwelmaaboj5vvuu4767.png-wh_50 "/>

# # # #5. uniq###

Sort file |uniq-c # # Remove redundancy and count redundancy times

- D # # show redundant rows

650) this.width=650; "Src=" Http://s5.51cto.com/wyfs02/M01/89/F2/wKiom1gibWij7U97AAAth-6ws2k914.png-wh_500x0-wm_3 -wmp_4-s_3150892380.png "title=" image 15.png "alt=" wkiom1gibwij7u97aaath-6ws2k914.png-wh_50 "/>

- u # # show unique rows

650) this.width=650; "Src=" Http://s2.51cto.com/wyfs02/M01/89/EE/wKioL1gibXbyjW9DAAAviGsUsuo824.png-wh_500x0-wm_3 -wmp_4-s_4112625312.png "title=" image 16.png "alt=" wkiol1gibxbyjw9daaavigsusuo824.png-wh_50 "/>

# # # #6. sed####

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

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

sed-i File # # Enter the converted content into the specified file

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

sed xd # # masking specified lines

sed xp # # Copy the specified row

sed-n XP # # only shows the reference

#######

. Sed # # Control flow output

sed ' s/nologin/westos/g ' passwd # # Nologin in the replacement output is westos

## replace the output with 1-5 nologin Span style= "font-family: ' Times New Roman ';" >wesots

sed '/games/,/nobody/s/nologin/westos/g ' passwd # # Replace the Games characters in the output to Nobody characters between nologin Westos

sed-e ' s/nologin/westos/g '-e ' s/sbin/lee/g ' passwd # # multiple substitution policies with- e connection

sed 3d passwd # # does not display the third line in the file

sed 3,7d file # # does not show 3-7 lines in the file

sed 3,7p file # # repeats the 3-7 lines in the file

sed-n 3,7p File # # shows only 3-7 lines in the file


Shell script 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.