Linux regular match Little note

Source: Internet
Author: User

1. Using a regular match file name

# # grep-n ' [^\/][a-za-z0-9]*[.a-za-z0-9][a-za-z0-9]*$ ' Regular_express.txt

/etc/init.d/hello.h

/etc/init.d/hehe



2. Using SED to extract the NIC IP

(1)

# ifconfig eth0 |grep ' inet addr '

inet addr:192.168.211.129 bcast:192.168.211.255 mask:255.255.255.0

(2)

# ifconfig eth0 |grep ' inet addr ' | Sed ' s/^.*addr://g '

192.168.211.129 bcast:192.168.211.255 mask:255.255.255.0

(3)

# ifconfig eth0 |grep ' inet addr ' | Sed ' s/^.*addr://g ' | Sed ' s/bcast.*$//g '

192.168.211.129

3.

(1) filter ' man '

# cat/etc/man.config |grep-n ' man '

(2) Replace the contents of the sentence that begins with # with an empty

# cat/etc/man.config |grep-n ' man ' | Sed ' s/#.*$//g '

11:

17:

18:

19:

39:

41:

43:manpath/usr/man

44:manpath/usr/share/man

45:manpath/usr/local/man

46:manpath/usr/local/share/man

47:manpath/usr/x11r6/man

(3) Delete empty lines

# cat/etc/man.config |grep ' man ' |sed ' s/#.*$//g ' | Sed '/^$/d '

Manpath/usr/man

Manpath/usr/share/man

Manpath/usr/local/man

Manpath/usr/local/share/man

Manpath/usr/x11r6/man


Linux regular match Little note

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.