Suppose I have a file like this:
d,e,c,g,v,c,w,r
g,c,d,c,s,c,g,r
d,y,c,w,t,g,c,f
Now I want to print the column (without the comma delimiter) which appears just after the first 'c' in each row.So my output will look like this
g
d
w
I have tried the code:
awk -F"," '{for (i=1;i<=NF;i++) if ($i == "c") {print $(i+1)};}' filename
But in output I'm getting the columns which appears after each 'c'. I only want the column which appears after the first 'c' . How to solve the problem preferably using awk.
Thanks in advance