Go on Shell

Source: Internet
Author: User

Shell Bash is the most commonly used script in Linux. You can write Common commands such as grep sed awk.

When grep is used, we need to think of regular expressions.

 

The row starting with a lowercase letter is listed.
Grep-n '^ [A-Z]'
OO cannot start with lowercase letters
Grep-n '[^ A-Z] oo'
Do not want to start with an English letter
Grep-n' ^ [^ A-Za-Z]'
The row whose end ends with the decimal point (.)
Grep-n' \. $ '!. For conversion
Which line is blank 』
Grep-n '^ $'
As long as there is a G
Grep-N 'G * G'
Start with G and end with G
Grep-N 'G. * G'

Egrep-V '^ $ | ^ #' removes the blank line and the first line

 

Sed '2, 5d 'del 2 to 5 row

Sed '2a XXX' insert XXX after 2 row

Sed '2, 5C XXX' replace 2-5 rows with xxx

Sed-n'5, 7p' only lists 5 to 7 rows

Sed '/string to be replaced/New String/G'

Sed-I op directly operates on the file

 

 

 

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.