awk is also a data processing tool and is a basic language that can customize variables, loop array regular functions, etc.
awk-f delimiter ' commands command ' file
' Condition {Execute} ' condition {execute} ' multiple conditions can use various action symbols
<><==> = = = ~ Matching!~ mismatch
For example
650) this.width=650; "height=" 203 "src=" http://b288.photo.store.qq.com/psb?/81c1194a-ff39-4e50-b1b1-40057b06260f/ 79o2uurmakulvmjfy99px5naz3jlhfdemx4.oputm80!/b/dcabaaaaaaaa&bo=jallaaaaaaafen4! "width=" 548 "style=" vertical-align:top; "alt=" dcabaaaaaaaa&bo=jallaaaaaaafen4! "/>
650) this.width=650; "height=" 271 "src=" http://b287.photo.store.qq.com/psb?/81c1194a-ff39-4e50-b1b1-40057b06260f/ kbp08w2bt4omh*foekiajybs8tbfvqfxdpipgqrfwuw!/b/db8baaaaaaaa&bo=rgipaqaaaaafehk! "width=" 582 "style=" vertical-align:top; "alt=" db8baaaaaaaa&bo=rgipaqaaaaafehk! "/>
Conditions can also be used && | | All can
650) this.width=650; "height=" 347 "src=" http://b287.photo.store.qq.com/psb?/81c1194a-ff39-4e50-b1b1-40057b06260f/ pmyukj9n.l*.0e*zlstniewnwvoxvjs6k5yt1jkathy!/b/db8baaaaaaaa&bo=yajbaqaaaaafekm! "width=" 712 "style=" vertical-align:top; "alt=" db8baaaaaaaa&bo=yajbaqaaaaafekm! "/>
The awk begin area is an area that is output ahead of the execution of the condition end is the last output, the middle can be inserted in the normal condition, followed by the operation
650) this.width=650; "height=" 202 "src=" http://b288.photo.store.qq.com/psb?/81c1194a-ff39-4e50-b1b1-40057b06260f/ vysvqa2kscd3g7tfw2kps3onk49ka6msj0hfuv.mtfo!/b/dcabaaaaaaaa&bo=tapkaaaaaaafely! "width=" 844 "style=" vertical-align:top; "alt=" dcabaaaaaaaa&bo=tapkaaaaaaafely! "/>
awk ' can be used in the middle of various regular and so on '
A function is a technique that is often used in automation scripts and needs to be written on its own. A simple script
The most basic of this script is to cancel the empty lines in the file, where sed I do is the screen output if you want to directly delete only need to add-I
650) this.width=650; "height=" 505 "src=" http://b288.photo.store.qq.com/psb?/81c1194a-ff39-4e50-b1b1-40057b06260f/ 4cwnupx4eayhp*gm0o1icwed4o4grki5vjj3osxtiag!/b/dcabaaaaaaaa&bo=dal5aqaaaaafel0! "width=" 628 "style=" vertical-align:top; "alt=" dcabaaaaaaaa&bo=dal5aqaaaaafel0! "/>
Edit script is heavy and far ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-eq equals
-
-ne not equals
-
-gt greater than
-
-lt less than
-
-le is less than or equal to
-
-ge is greater than or equal to
-
-z empty string
-
= two words typeface etc.
-
!= two characters are not equal to
-
-n non-empty string
Summarize:
Document comparison operators
-e filename If filename exists, true [-e/var/log/syslog]
-d filename If filename is a directory, then true [-d/tmp/mydir]
-F filename True if filename is a regular document [-f/usr/bin/grep]
-L filename True if filename is a symbolic link [-l/usr/bin/grep]
-r filename If filename is readable, true [-r/var/log/syslog]
-W filename if filename is writable, true [-w/var/mytmp.txt]
-X filename is true if filename is executable [-l/usr/bin/grep]
This article is from the "11627223" blog, please be sure to keep this source http://11637223.blog.51cto.com/11627223/1911984
Shell-awk Common usage