Can field separator in awk encompass multiple characters?

后端 未结 5 1427
野的像风
野的像风 2020-12-31 07:05

Can I use a field separator consisting of multiple characters? Like I want to separate words which contain quotes and commas between them viz.

\"School\",\"College\"

5条回答
  •  灰色年华
    2020-12-31 07:34

    yes, FS could be multi-characters. see the below test with your example:

    kent$  echo '"School","College","City"'|awk -F'","|^"|"$' '{for(i=1;i<=NF;i++){if($i)print $i}}'
    School
    College
    City
    

提交回复
热议问题