Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Preserve new line characters when editing remote file from WinSCP

As I understand, it is that if I create a file on my Solaris server I will automatically get LF ending line.

Setup: I am logged on to a Windows server remotely (with no internet as long as I am connected to it). On this Windows server I am using Winscp to log onto a solaris server.

Issue: When I create a text file on the Solaris server (using WinSCP), I can open it using Notepad++. When I open the file it always has CRLF as the newline character, I don't know why. Then I changed the CRLF character to LF by using 'find and replace' from '/r/n' to '/n'. When I find and replace I see that the newline character has been changed to 'LF'. However as soon as I save the file and reopen it we are back with 'CRLF'.

Could this be that notepadd++ is showing me false character maybe something to do with opening a Solaris file through WinSCP?

Or I should make the file using shell scripting (bash)?

Even if I make a file using shell script, how can I be sure that newline character in that file is LF not CRLF (is there a way of doing it on the terminal?), because right now I am using Notepad++ and it always shows CRLF as the newline character when I reopen the file.

Aim: What I want is simply create any text file with 'LF' as the newline character. I am using Solaris bash.

like image 242
ITguy Avatar asked Oct 18 '25 14:10

ITguy


1 Answers

WinSCP by default does not convert the EOL sequence for editing files in an external editor, except if the editor is Windows built-in notepad.exe.

So you must have enabled the conversion in preferences yourself.

See Force text transfer mode for files edited in external editor option on Editor Preferences dialog:

enter image description here

With the option turned off, you will get file opened in Notepad++ exactly as it is stored on the server.

like image 143
Martin Prikryl Avatar answered Oct 22 '25 01:10

Martin Prikryl