Linux Regular Expression bre

Source: Internet
Author: User

is a set of cabinets and methods for handling strings, which are handled in the unit of behavior

With the aid of special symbols, you can quickly filter and replace certain specific strings.

awk sed grep

^word has word start

wrod$ has word end

# grep "^i" Hequan # grep-i "^i" Hequan case insensitive

# grep-i ". $" Hequan

. Delegates can only represent any one character

# grep "LI.E" Hequan

\ transfer symbol, remove the special meaning of the original character,

# grep-n "\." Hequan

*| Repeat 0 or more of the preceding characters.

# grep "490*448" Hequan

49000000000000048,49448

# grep "49.*448" Hequan # grep ". *" Hequan All # grep "^.*" Hequan

[]. Repeating special characters for character sets, # grep "H[ex]quan" Hequan find Hequan or Hxquan

[^word] Match does not include any characters that follow the ^

# grep "[^not Boog]" Hequan--color=auto

I am Hequan Linux teacher.

I like Chinese chess, table tennis.

111111111111111

49000000000000048,49448

# grep-e "[^0-9|,]" Hequan--color=auto

A\{n,m\} repeats N to M times, before a repeating character

A{n,} Repeat at least n times

A{n} repeats n times

# grep "490\{2,3\}" Hequan

# grep "490\{1,\}" Hequan

# grep "490\{4\}" Hequan--color=auto

Extended Regular expression: ERF

+ Repeat one or more of the preceding characters

# egrep "490+" Hequan

? Repeat 0 or one of the preceding characters

| A string that finds multiple symbols in or in a way

() find the "user group" string

# grep-e "H (Ex|equa) n" Hequan

Mans grep

/regular

# ifconfig Eth0 | grep "inet addr" |cut-d ":"-f2 | Cut-d ""-f1

192.168.10.10

# ifconfig Eth0 | grep "inet addr" |awk-f ":" ' {print $} ' | awk ' {print '} '

# ifconfig Eth0 | grep "inet addr" | Awk-f "[:]" ' {Print $13} '

192.168.10.10

# ifconfig Eth0 | grep "inet addr" | Awk-f "[:]+" ' {Print $4} '

# echo---1:----2 | Awk-f ' [-:]+ ' {print $} '

2

# ifconfig Eth0 | Sed-n ' 2p '

Awk-f "[-:]+"

$ $NF The last column of the whole line NF NR

# ifconfig Eth0 | Sed-n '/inet addr/p '

# ifconfig Eth0 | Sed-n '/inet addr/p ' |sed ' s#^.*addr:# #g '

# ifconfig Eth0 | Sed-n '/inet addr/p ' |sed ' s#^.*addr:# #g ' | Sed ' s# bc.*$# #g '

# ifconfig Eth0 | grep "HWaddr" |awk-f "[]+" ' {print $} '

00:0c:29:e1:35:13

.*

# ifconfig Eth0 | Sed-n ' s#^.*addr:\ (. *\) BCAST.*$#\1#GP '

192.168.10.10

650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>

# ifconfig Eth0 | Sed-n ' s#^.*hwaddr \ (. *\) #\1#gp '

00:0c:29:e1:35:13

# sed ' s#\ (dd\) \ (xx\) #\1#g ' a.txt

Dd

# ifconfig Eth0 | Sed-n ' s#^.*dr:\ (. *\) bcast:\ (. *\) ma.*$#\1 \2#GP '

192.168.10.10 192.168.10.255

# ifconfig Eth0 | Sed-n ' s#^.*hwaddr \ (. *\) #\1#gp '

00:0c:29:e1:35:13

4 2 1 R W x

# STAT/XX

# stat/xx |sed-n 4p| Awk-f "[/(]" ' {print $} '

0644

# Stat/xx | head-4 |  Tail-1 | Awk-f "[/(]" ' {print $} '

0644

# Stat/xx | Sed-n ' s#^.*ess: (0\ (. *\)/-.*$#\1#GP '

644

# Stat/xx | Sed-n ' s#^.* (\ (. *\)/-.*$#\1#GP '

0644

# stat-c%a/xx

644

# stat-c%a/xx

-rw-r--r--

# stat-c%b/xx

512

# stat-c%b/xx

0

# Stat/xx | Sed-n ' 4p ' | Awk-f "[(/]" ' {print $} '

0644

# Ll/xx | Cut-c 2-10 | TR rwx-4210 | Awk-f "" ' {print $1+$2+$3 $4+$5+$6 $7+$8+$9} '

644

# vi/etc/resolv.conf

Vi/etc/sysconfig/network-scripts/ifcfg-eth0

chmod 644 Hequan

# echo-n Hequan;echo Hequan No Line break

Hequanhequan

# echo-e "Hequan\Hequan"

Hequan Hequan

# echo-e "Hequan\nhequan"

Hequan

Hequan

# lang=en

# date ' +%y-%m-%d '

16-03-30

# date ' +%y-%m-%d '

2016-03-30

# date +%w

3

# date +%u

3

Cut

# echo ' Date +%f\%T '

2016-03-30 17:06:52

Tar

# tar zcvf/tmp/qwe2.tar.gz./etc/

# tar zcvf/tmp/qwe-$ (date +%f-%t). tar.gz./etc/

# tar zcvf/tmp/qwe-$ (date +%w). tar.gz./etc/

# find/log-type F-name "*.log"-mtime +7 |xargs rm-f

#/usr/sbin/ntpdate Time.ntvs.gov

# echo $PATH

/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin

# cal

# which ifconfig

/sbin/ifconfig

# Export path= $PATH: $HOME/bin:/sbin

# echo $PATH

/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/root/bin:/sbin

# Vi/etc/profile

# date +%f--date= ' 3 day ago '

2016-03-24

# grep-v "^$" xx

Hequan

Hequan

# sed '/^$/d ' xx

# awk/^[^$]/XX

650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>

Which ifconfig

Whereis

Find

LOCATE-N 1 CP

# Find/-name "CP"

W.H.O.

Lastlog

Shutdown-h now Halt Poweroff

Init 6

Logout

Exit

650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>


Linux Regular Expression bre

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.