Awk error message targeting a parentheses -
i'm running awk command cant find why keeps on telling me wrong, variables instantiated (i have replaced them string here show error, error same), braces closed, advice?
key=$(echo "hello,there" | awk -f"," -v index=2 '{for(i=1; i<=nf; i++) if ($i ~ $index) print i}')
i'm not perfect awk user, cant spot issue here advice?
index
built-in function (keyword) cannot use variable name. change to:
awk -f"," -v idx=2 '{for(i=1; i<=nf; i++) if ($i ~ idx) print i}')
the field specifier, $
, prefixing idx
not correct, want use string is.
Comments
Post a Comment