Difference between DOS and Unix formats

Solved
smed_79 Posted messages 1298 Registration date   Status Contributor Last intervention   -  
smed_79 Posted messages 1298 Registration date   Status Contributor Last intervention   -
Hello,
I have a text file that is 634 KB when saved in DOS format and 611 KB in Unix format.

I would like to know what the difference is between the two file formats Unix & DOS?
Are Unix files usable on Windows?
If so, how can you convert a DOS file to Unix via the command prompt?

Thank you very much.

Configuration: ASUS G46VW | Manjaro 0.8.9 | LibreOffice | Firefox

2 answers

zipe31 Posted messages 34620 Registration date   Status Contributor Last intervention   6 501
 
Hi,

I think the difference in size mainly comes from the line endings, which differ depending on the system.
Unix uses the newline character (\n), while DOS also uses this character but preceded by a carriage return (\r\n).

As for modifying a file from the command line, under GNU/Linux (Unix), there are two utilities for that,
dos2unix
and
unix2dos
which convert the format to each other.

You can also do this with tools like sed, perl, or others.

See in the FAQ: DOS (CRLF) / UNIX (LF) carriage return conversion

--
Zen my nuggets ;-)
Do something for the environment, close your windows and adopt a penguin. <('')
2
smed_79 Posted messages 1298 Registration date   Status Contributor Last intervention   850
 
Thank you very much, I understand well :) and I also found this link http://soft.zoneo.net/Linux/dos_et_unix.php
0
smed_79 Posted messages 1298 Registration date   Status Contributor Last intervention   850
 
I continued to search to find ...
Sed - Conversion of carriage returns DOS (CRLF) / UNIX (LF) https://forums.commentcamarche.net/forum/affich-37620064-sed-conversion-retours-chariots-dos-crlf-unix-lf
0
smed_79 Posted messages 1298 Registration date   Status Contributor Last intervention   850
 
# perl -pe 's/\n/\r\n/' unix-file > dos-file
0