LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

d2u

DOS to Unix line ending converter

TLDR

Convert a file from DOS to Unix line endings
$ d2u [file.txt]
copy
Convert multiple files
$ d2u [file1.txt] [file2.txt] [file3.txt]
copy
Convert and keep backup of original
$ d2u -b [file.txt]
copy
Convert with custom backup suffix
$ d2u -b -e [.bak] [file.txt]
copy
Convert to a new file instead of in-place
$ d2u -n [input.txt] [output.txt]
copy
Convert files in place silently
$ d2u -q [file.txt]
copy

SYNOPSIS

d2u [options] [file...]

DESCRIPTION

d2u converts text files from DOS/Windows line endings (CRLF - Carriage Return + Line Feed) to Unix line endings (LF - Line Feed only). It is an alias or alternative name for the dos2unix utility.The tool modifies files in place by default, making it convenient for batch conversion. It automatically detects binary files and skips them unless forced. Multiple files can be processed in a single command.This conversion is commonly needed when transferring text files from Windows to Unix/Linux systems, or when working with files that have mixed line endings from version control systems.

PARAMETERS

FILE

File(s) to convert. Converts in place by default.
-b, --backup
Keep backup of original file.
-e SUFFIX, --extension SUFFIX
Backup file extension (default: .bak).
-n, --newfile infile outfile
Convert infile and write to outfile (new file mode).
-q, --quiet
Quiet mode, suppress output.
-k, --keepdate
Preserve original file timestamp.
-f, --force
Force conversion even on binary files.
-l, --newline
Add an additional newline after each converted line break.
-o, --oldfile
In-place conversion mode (default).
-h, --help
Display help information.

CAVEATS

Binary files may be corrupted if converted; the tool attempts to detect and skip them. In-place conversion without backup can lose original data. Some files may have intentional CRLF sequences that should not be converted.

HISTORY

d2u is typically an alias for dos2unix, which has been a standard Unix utility for decades. The need for line ending conversion arose from the different conventions adopted by CP/M, DOS, and Unix in the late 1970s and 1980s.

SEE ALSO

dos2unix(1), unix2dos(1), u2d(1), tr(1)

Copied to clipboard
Kai