dos2unix

string

Converts Windows-style line endings (CRLF) to Unix-style (LF)

Syntax

dos2unix(string)

Parameters

string (string)

The string to convert

Returns

string

String with Unix-style line endings

Examples

Input:
dos2unix("line1\r\nline2")
Output:
"line1\nline2"
Input:
"text\r\n" | dos2unix
Output:
"text\n"

The dos2unix() function converts Windows-style line endings (CRLF: \r\n) to Unix-style line endings (LF: \n).

Usage

Use dos2unix() when processing text files from Windows systems on Unix/Linux systems, or when standardizing line endings across platforms.

Related Functions