dos2unix: Binary symbol found, skipping binary file
Asked Answered
D

1

10

I am currently having an issue where my script is failing when trying to execute the dos2unix command on a file.

This is what I have in the script:

dos2unix -n data/file data/tmp_file
dos2unix: Binary symbol found at line 21107611
dos2unix: Skipping binary file data/input/DATA.txt
mv -f data/tmp_file data/input/DATA.txt
mv: cannot stat ‘data/tmp_file’: No such file or directory

I went to the line is question and I have a "^@" here. What is this and how do i get my script to work using the dos2unix command?

{128392938928392838123129381298398129^@ 

Thanks

Dympha answered 13/12, 2018 at 14:6 Comment(0)
L
18

The ^@ is Vim's representation of a null byte; cp. :help <Nul>

Ordinary text files do not contain null characters. Binary files typically have many null characters, and they would become corrupted if converted as a whole; that's why dos2unix refuses to convert it.

You have several options:

  • That null character may have been inserted by accident or is garbage. Edit the file (in Vim) or recreate it. If you're using Vim, you can do the conversion in it as well (via :help ++ff, e.g. :w ++ff=unix). Command-line tools like dos2unix still have their use for non-interactive invocations.
  • That null character belongs there. The dos2unix command has a -f|--force option to enforce conversion.
Limelight answered 13/12, 2018 at 14:13 Comment(1)
Thanks, will try out the -f option. I think it does belong there.Dympha

© 2022 - 2024 — McMap. All rights reserved.