The first command passes an argument to
gawk
. The argument isN
and the value assigned toN
is the value of the bash variable$N
.The second command splits the awk variable
$0
into strings based on the regex/\<\w*\>/
. It returns the number of strings that it was able to split. See http://www.gnu.org/software/gawk/manual/gawk.html#String-Functions. The regex is comopsed of\<
(start of word boundary),\w
(word constituent),\>
(end of word boundary). See http://www.gnu.org/software/gawk/manual/gawk.html#GNU-Regexp-OperatorsThe third command is a special feature of
gawk
version 4.1. That is used to traverse arrays in specific order (in afor
loop).. See http://www.gnu.org/software/gawk/manual/gawk.html#Scanning-an-Array
Question
I am trying to understand gawk in shell scripting.
How does this command work?
gawk -vN="$N"
and this split based on what
n=patsplit($0,a,/\<\w*\>/,s)
and this
PROCINFO["sorted_in"]="@val_num_desc"
How does it work?
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow