0

I need to print the value which is double quoted and having delimiter as a value.

Sample data:

a,"b,c,d",e  
a,b,c  
a,,  
c,,  

command provided by @user4453924 How to make awk ignore the field delimiter inside double quotes?

awk '{while(match($0,/("[^"]+",|[^,]*,|([^,]+$))/,a)){
     $0=substr($0,RSTART+RLENGTH);b[++x]=a[0]}
     print b[2] ;x=0}' file

So when using the above command provided by @user4453924 , it's resulting only 2 rows as "b,c,d",
b,

where as expected output is(4 rows, last 2 with null value) as: "b,c,d",
b,
,
,

and Its working fine when last row is having some value at 2nd position but if last row is not having any value then its not considering that row or above one.

ANY HELP?

RavinderSingh13
  • 130,504
  • 14
  • 57
  • 93
  • 1
    Can you explain yourself clearly pls ? –  Aug 21 '20 at 17:12
  • Please post your sample output more clearly in code tags in your question as it's not clear as of now. – RavinderSingh13 Aug 22 '20 at 18:37
  • Input data A, "b,c d",e "a,c",b,"d,e" b,, ,,d I want to print column value based on input argument as:. If I give input argument as 2 and delimeter as "," then it should give output as ------------------- row 1 b,c,d row 2 b row 3 row 4 ------------------- – sandeep gupta Aug 23 '20 at 04:54

0 Answers0