0

I have a variable, var, that contains: XXXX YY ZZZZZn aaa,bbb,ccc

All I want is aaa in the second line. I tried: out=(echo "var" | awk ‘NR==2{sub(",.*","")}’ ) but I get no output other than an error message. The field denotation "medlist" could not be parsed … I really want to learn awk/regex syntax.