GNU nano 2: DOS Format or Mac Format on Linux

27,116

Solution 1

Use neither: enter a filename and press Enter, and the file will be saved with the default Unix line-endings (which is what you want on Linux).

If nano tells you it’s going to use DOS or Mac format (which happens if it loaded a file in DOS or Mac format), i.e. you see

File Name to Write [DOS Format]:

or

File Name to Write [Mac Format]:

press AltD or AltM respectively to deselect DOS or Mac format, which effectively selects the default Unix format.

Solution 2

Unix, Linux, new macOS \n DOS, Windows \r\n old Mac OS \r

Save in DOS Format, then cd to the folder where you have the file and perform:

cp -i ./<file> /home/petr/Documents/whatIfBackups/<file> to back it up and then re-format from the dos to unix line endings:

sudo dos2unix <file>

(file <file> shows the status of line endings. "ASCII text" stands for Unix/Linux/new macOS. Alternatively you could also save in Mac Format and then re format by sudo mac2unix <file>.)

Share:
27,116

Related videos on Youtube

JoKalliauer
Author by

JoKalliauer

Updated on September 18, 2022

Comments

  • JoKalliauer
    JoKalliauer over 1 year

    Which format (Mac or DOS) should I use on Linux PCs/Clusters?

    I know the difference:

    • DOS format uses "carriage return" (CR or \r) then "line feed" (LF or \n).
    • Mac format uses "carriage return" (CR or \r)
    • Unix uses "line feed" (LF or \n)

    I also know how to select the option:

    • AltM for Mac format
    • AltD for DOS format

    But there is no UNIX format.

    Then save the file with Enter.

    enter image description here