IFS separate a string like “Hello”,“World”,“this”,“is, a boring”, “line”

前端 未结 3 1596
夕颜
夕颜 2021-01-29 07:10

I\'m trying to parse a .csv file and I have some problems with IFS. The file contains lines like this:

\"Hello\",\"World\",\"this\",\"is, a boring\",\"line\"
         


        
3条回答
  •  自闭症患者
    2021-01-29 07:26

    give this a try:

    sed 's/","/"\n"/g' <<<"${line}"
    

    sed has a search and replace command s which is using regex to search pattern.

    The regex replaces , in "," with new line char.

    As a consequence each element is on a separate line.

提交回复
热议问题