notepad++solariswinscp

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.


Solution

  • What winscp has done was that it opened an internal text editor for you to enter the text content. It saved to a temporary file locally on your Windows machine with the name you specified and finally transferred it in ascii mode to the Solaris.

    When you downloaded it to your Windows, it was likely that it was downloaded in ascii mode too. As a result the change line characters were converted to Windows flavor CR+LF.

    It looks ok. If you want to make sure of it, I would suggest you check the file content with an editor on Solaris such is vi. Winscp has a menu option Commands -> Open in PuTTY for you.