Skip to main content
The 2024 Developer Survey results are live! See the results
added 32 characters in body
Source Link
StackzOfZtuff
  • 2.9k
  • 1
  • 30
  • 28
  • It will output with CRLF line endingsterminators for DOS/Windows line terminators.
  • It will output with CR line endingsterminators for MAC line terminators.
  • It will just output text for Linux/Unix "LF" line terminators. (So if it does not explicitly mention any kind of line terminators then this means: "LF line terminators".)
  • $ echo -ne '1\n2\r\n3\r' | file -k -
    /dev/stdin: ASCII text, with CRLF, CR, LF line terminators

Let's try a little quiz: I've got some files. And one of these files has different line endingsterminators. Which one?

Huh. It's not telling me the line endingsterminators. And I already knew that those were cert files. I didn't need "file" to tell me that.

So that tells you that: yup, "0.example.end.cer" must be the odd man out. But what kind of line endingsterminators are there? Do you know the dos2unix output format by heart? (I don't.)

Excellent! Now we know that our odd file has DOS (CRLF) line endingsterminators. (And the other files have Unix (LF) line endingsterminators. This is not explicit in this output. It's implicit. It's just the way file expects a "regular" text file to be.)

Good. Now all certs have Unix line endingsterminators.

  • It will output with CRLF line endings for DOS/Windows line terminators.
  • It will output with CR line endings for MAC line terminators.
  • It will just output text for Linux/Unix "LF" line terminators. (So if it does not explicitly mention any kind of line terminators then this means: "LF line terminators".)
  • echo -ne '1\n2\r\n3\r' | file -k -
    /dev/stdin: ASCII text, with CRLF, CR, LF line terminators

Let's try a little quiz: I've got some files. And one of these files has different line endings. Which one?

Huh. It's not telling me the line endings. And I already knew that those were cert files. I didn't need "file" to tell me that.

So that tells you that: yup, "0.example.end.cer" must be the odd man out. But what kind of line endings are there? Do you know the dos2unix output format by heart? (I don't.)

Excellent! Now we know that our odd file has DOS (CRLF) line endings. (And the other files have Unix (LF) line endings. This is not explicit in this output. It's implicit. It's just the way file expects a "regular" text file to be.)

Good. Now all certs have Unix line endings.

  • It will output with CRLF line terminators for DOS/Windows line terminators.
  • It will output with CR line terminators for MAC line terminators.
  • It will just output text for Linux/Unix "LF" line terminators. (So if it does not explicitly mention any kind of line terminators then this means: "LF line terminators".)
  • $ echo -ne '1\n2\r\n3\r' | file -k -
    /dev/stdin: ASCII text, with CRLF, CR, LF line terminators

Let's try a little quiz: I've got some files. And one of these files has different line terminators. Which one?

Huh. It's not telling me the line terminators. And I already knew that those were cert files. I didn't need "file" to tell me that.

So that tells you that: yup, "0.example.end.cer" must be the odd man out. But what kind of line terminators are there? Do you know the dos2unix output format by heart? (I don't.)

Excellent! Now we know that our odd file has DOS (CRLF) line terminators. (And the other files have Unix (LF) line terminators. This is not explicit in this output. It's implicit. It's just the way file expects a "regular" text file to be.)

Good. Now all certs have Unix line terminators.

typo
Source Link
StackzOfZtuff
  • 2.9k
  • 1
  • 30
  • 28

file will usually be enough. But for tough cases try file -k or dosunixdos2unix -ih.

Short version: file -k somefile.txt will tell you. line terminators:

  • It will output with CRLF line endings for DOS/Windows line endingsterminators.
  • It will output with CR line endings for MAC line endingsterminators.
  • It will just output text for Linux/Unix "LF" line endingsterminators. (So if it does not explicitly mention any kind of line endingsterminators then this means: "LF line endings"terminators".)

And for extra weird cases: When you have mixed line terminators:

  • echo -ne '1\n2\r\n3\r' | file -k -
    /dev/stdin: ASCII text, with CRLF, CR, LF line terminators

file will usually be enough. But for tough cases try file -k or dosunix -ih.

Short version: file -k somefile.txt will tell you.

  • It will output with CRLF line endings for DOS/Windows line endings.
  • It will output with CR line endings for MAC line endings.
  • It will just output text for Linux/Unix "LF" line endings. (So if it does not explicitly mention any kind of line endings then this means: "LF line endings".)

file will usually be enough. But for tough cases try file -k or dos2unix -ih.

Short version: file -k somefile.txt will tell you line terminators:

  • It will output with CRLF line endings for DOS/Windows line terminators.
  • It will output with CR line endings for MAC line terminators.
  • It will just output text for Linux/Unix "LF" line terminators. (So if it does not explicitly mention any kind of line terminators then this means: "LF line terminators".)

And for extra weird cases: When you have mixed line terminators:

  • echo -ne '1\n2\r\n3\r' | file -k -
    /dev/stdin: ASCII text, with CRLF, CR, LF line terminators
deleted 7 characters in body
Source Link
StackzOfZtuff
  • 2.9k
  • 1
  • 30
  • 28
  • It will output with CRLF line endings for DOS/Windows line endings.
  • It will output with CR line endings for MAC line endings.
  • And for Linux/Unix line "LF" itIt will just output text for Linux/Unix "LF" line endings. (So if it does not explicitly mention any kind of line endings then this implicitly means: "LF line endings".)
  • It will output with CRLF line endings for DOS/Windows line endings.
  • It will output with CR line endings for MAC line endings.
  • And for Linux/Unix line "LF" it will just output text. (So if it does not explicitly mention any kind of line endings then this implicitly means: "LF line endings".)
  • It will output with CRLF line endings for DOS/Windows line endings.
  • It will output with CR line endings for MAC line endings.
  • It will just output text for Linux/Unix "LF" line endings. (So if it does not explicitly mention any kind of line endings then this means: "LF line endings".)
added 126 characters in body
Source Link
StackzOfZtuff
  • 2.9k
  • 1
  • 30
  • 28
Loading
Fix inverted CR/LF
Source Link
Cameron Tacklind
  • 6.7k
  • 2
  • 39
  • 49
Loading
added 108 characters in body
Source Link
StackzOfZtuff
  • 2.9k
  • 1
  • 30
  • 28
Loading
Commonmark migration
Source Link
Loading
added 1061 characters in body
Source Link
StackzOfZtuff
  • 2.9k
  • 1
  • 30
  • 28
Loading
+summary at top
Source Link
StackzOfZtuff
  • 2.9k
  • 1
  • 30
  • 28
Loading
+summary at top
Source Link
StackzOfZtuff
  • 2.9k
  • 1
  • 30
  • 28
Loading
+further reading
Source Link
StackzOfZtuff
  • 2.9k
  • 1
  • 30
  • 28
Loading
Source Link
StackzOfZtuff
  • 2.9k
  • 1
  • 30
  • 28
Loading