LinuxCommandLibrary

mac2unix

TLDR

Convert file line endings

$ mac2unix [path/to/file]
copy
Create new file with Unix endings
$ mac2unix -n [path/to/file] [path/to/new_file]
copy
Display file info
$ mac2unix -i [path/to/file]
copy
Handle BOM (Byte Order Mark)
$ mac2unix --keep-bom [path/to/file]
copy

SYNOPSIS

mac2unix [options] [file...]

DESCRIPTION

mac2unix converts macOS-style line endings (CR) to Unix-style line endings (LF). It is part of the dos2unix package and handles text file format conversions.

PARAMETERS

-n, --newfile SRC DST

Write output to new file
-i, --info
Display file information
--keep-bom
Keep Byte Order Mark
--add-bom
Add Byte Order Mark
--remove-bom
Remove Byte Order Mark
-k, --keepdate
Keep original file date
-q, --quiet
Quiet mode

CAVEATS

Classic Mac OS (pre-OS X) used CR line endings. Modern macOS uses Unix LF endings. Only needed for legacy files.

SEE ALSO

Copied to clipboard