Replace comma with newline in sed on MacOS?

后端 未结 13 1967
借酒劲吻你
借酒劲吻你 2020-11-27 09:27

I have a file of id\'s that are comma separated. I\'m trying to replace the commas with a new line. I\'ve tried:

sed \'s/,/\\n/g\' file

b

相关标签:
13条回答
  • 2020-11-27 10:29

    MacOS is different, there is two way to solve this problem with sed in mac

    • first ,use \'$'\n'' replace \n, it can work in MacOS:

      sed 's/,/\'$'\n''/g' file
      
    • the second, just use an empty line:

      sed 's/,/\
      /g' file
      
    • Ps. Pay attention the range separated by '

    • the third, use gnu-sed replace the mac-sed

    0 讨论(0)
提交回复
热议问题