Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

dos2unix: Binary symbol found, skipping binary file

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

like image 862
MR JACKPOT Avatar asked Dec 13 '18 14:12

MR JACKPOT


1 Answers

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.
like image 200
Ingo Karkat Avatar answered Sep 23 '22 15:09

Ingo Karkat