shell - How to ignore white space and comma when reading from a file -


i have comma separated file , need extract third field each line.file test.txt has following contents:

6,string decimal without default,cast($src_fld decimal(15,2) $tgt_fld  7,string interger without default,cast($src_fld integer) $tgt_fld                 10,default no rule,'$default' $tgt_fld 

cat test.txt | awk -f, '{print $3}'

if write above command ,i incorrect output :

> cast($src_fld decimal(15 > cast($src_fld integer) $tgt_fld > '$default' $tgt_fld 

can please tell me how achieve it.i need write in loop further processing can done later. please note each third field may contain white space , comma(,).

if, say, first 2 fields don't contain comma, can use cut comma field delimiter:

$ cut -d ',' -f 3- test.txt  cast($src_fld decimal(15,2) $tgt_fld  cast($src_fld integer) $tgt_fld                 '$default' $tgt_fld 

Comments

Popular posts from this blog

php - Extract Text from HTTP referer -

Receive udp packets in android gstreamer -

authentication - ASP.NET Core 1.0. Bearer Token, cannot access custom claims -