網頁

2010年5月11日 星期二

AWK

Pattern { Action }
     -> If Pattern is true, do Action.

Pattern will exploit "Relational Expression".


[Relational Expression]
>, <, ==, != ...etc.
~(match)
!~(Not Match)


[EXE]
1. awk -f awkfile [file]
2. $ awk 'shell action' [file]
3. script and chmod +x to instruction

[awk action format]
awk 'pattern' file : display rows which match patterns
awk '{action}' file : execute the action in {} for every row
awk 'pattern{action}' file: execute the action for the rows which match patterns

[argument passing]
awk -v varible 'pattern' file
ex: awk -v avar="$svar" '$0 == avar' file

[Reference]
AWK tutorial

沒有留言: