Why is my Bash script adding to the beginning of files?

前端 未结 2 411
孤独总比滥情好
孤独总比滥情好 2021-02-04 03:18

I\'ve written a script that cleans up .csv files, removing some bad commas and bad quotes (bad, means they break an in house program we use to transform these files) using sed:

相关标签:
2条回答
  • 2021-02-04 03:49

    To get rid of these in GNU emacs:

    1. Open Emacs
    2. Do a find-file-literally to open the file
    3. Edit off the leading three bytes
    4. Save the file

    There is also a way to convert files with DOS line termination convention to Unix line termination convention.

    0 讨论(0)
  • 2021-02-04 03:50

    U+FEFF is the code point for a byte order mark. Your files most likely contain data saved in UTF-16 and the BOM has been corrupted by your 'cleaning process' which is most likely expecting ASCII. It's probably not a good idea to remove the BOM, but instead to fix your scripts to not corrupt it in the first place.

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