📜  notepad++ 转换 windows unix - Shell-Bash (1)

📅  最后修改于: 2023-12-03 15:33:12.222000             🧑  作者: Mango

Notepad++ 转换 Windows Unix - Shell-Bash

As a programmer, you may encounter the need to convert your script or file from Windows to Unix format or vice versa. Notepad++ is a popular text editor that can help you achieve this task quickly and easily.

Step 1: Open your File in Notepad++

First, open your file in Notepad++. You can do this by selecting File > Open or by dragging and dropping your file into the Notepad++ workspace.

Step 2: Check the Current Format

To check the current format of your file, select View > Show Symbol > Show End of Line. This will display a symbol at the end of each line, indicating the current format of your file.

Windows Format

If you see a CR LF symbol at the end of each line, this indicates that your file is in Windows format.

Unix Format

If you see a LF symbol at the end of each line, this indicates that your file is in Unix format.

Step 3: Convert to Unix Format

To convert your file to Unix format, select Edit > EOL Conversion > Unix (LF). This will convert all line endings to the Unix format.

Step 4: Convert to Windows Format

To convert your file to Windows format, select Edit > EOL Conversion > Windows (CR LF). This will convert all line endings to the Windows format.

Step 5: Save Your File

After converting your file to the desired format, save your file by selecting File > Save.

That's it! With Notepad++, converting your files from Windows to Unix format and vice versa is quick and easy.

# Convert file to Unix format
sed -i 's/\r//' filename.txt

# Convert file to Windows format
sed -i 's/$/\r/' filename.txt