in reply to Ascii upload ruins the file

Ah, no, you misunderstand. There are still two characters whether it is under DOS/WIN or Unix. They just happen to be backward from each other. What you are confused with is the fact that C and Perl and probably many other languages allow you to do the correct thing on which ever box you're on by using '\n' as a shortcut.

I stand corrected. I've been mistaken on this for years...

-Scott

Replies are listed 'Best First'.
Re^2: Ascii upload ruins the file
by ikegami (Patriarch) on May 19, 2005 at 14:44 UTC

    No, Unix does indeed use only \x0A as the line terminator.

    $ cat > test this is a test this is a test this is a test 12345678901234 $ od -t x1 test 000000 74 68 69 73 20 69 73 20 61 20 74 65 73 74 0a 74 000020 68 69 73 20 69 73 20 61 20 74 65 73 74 0a 74 68 000040 69 73 20 69 73 20 61 20 74 65 73 74 0a 31 32 33 000060 34 35 36 37 38 39 30 31 32 33 34 0a 000074 $ \ls -l test -rw------- 1 ikegami users 60 May 19 09:40 test

    Not only do you see only "0a" without any "0d" in the binary dump, The file size indicates FreeBSD uses only one (60/4 - 14 = 1) character for the newline. From experience, the same applies to Linux, SunOS/Solaris and AIX. The Macs do something different, but I'm not sure what.

      Here is the Mac (OS X) output:

      brucelowther:~ brucelowther$ cat > ~/tmp/test.txt this is a test this is a test this is a test 12345678901234 brucelowther:~ brucelowther$ hexdump -C ~/tmp/test.txt 00000000 74 68 69 73 20 69 73 20 61 20 74 65 73 74 0a 74 |this is a + test.t| 00000010 68 69 73 20 69 73 20 61 20 74 65 73 74 0a 74 68 |his is a +test.th| 00000020 69 73 20 69 73 20 61 20 74 65 73 74 0a 31 32 33 |is is a t +est.123| 00000030 34 35 36 37 38 39 30 31 32 33 34 0a |456789012 +34.| 0000003c

      Unemployed!