Gawk
From wikinotes
AWK is a scripting language that was originally designed for manipulating tables and presenting them in human-readable formats. It is useful on the commandline, I'd prefer to use a more powerful language than awk than use it for scripting.
WARNING:
There are two main variations of the unix coreutils (Gnu/BSD), each has different parameters etc. If you are expecting to use awk across different platforms, make no assumptions.
Notes
gawk usage gawk variables gawk datatypes gawk conditionals gawk loops gawk print
Syntax
match
match checks for a matching string, returns char number if found, otherwise returns a 0
match($0, "searchterm")echo "abcdefg" | awk '{var=match($0, "cd"); print var}' #> 3 echo "abcdefg" | awk '{var=match($0, "zef"); print var}' #> 0 echo "abcdefg" | awk '{ if(match($0, "cd")) { print "match found"; } }' #> match foundsystem
Executes a command in shell or cmd from an awk script. Assigning to a variable only gives return value (1,0)
system(ls -la);math
var+= 1; var=( (100/2) * 3 );References
http://www.funtoo.org/wiki/Awk_by_Example,_Part_1 http://www.math.utah.edu/docs/info/gawk_7.html