📅  最后修改于: 2023-12-03 15:33:12.222000             🧑  作者: Mango
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.
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.
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.
If you see a CR LF
symbol at the end of each line, this indicates that your file is in Windows format.
If you see a LF
symbol at the end of each line, this indicates that your file is in 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.
To convert your file to Windows format, select Edit > EOL Conversion > Windows (CR LF). This will convert all line endings to the Windows format.
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