4

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.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
ITguy
  • 847
  • 2
  • 10
  • 25
  • I have used dos2unix but the problem remains that I am unable to verify if the newline character is LF or CRLF. – ITguy Sep 25 '17 at 07:52

3 Answers3

2

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.

ITguy
  • 847
  • 2
  • 10
  • 25
chingNotCHing
  • 394
  • 1
  • 9
  • Can you please suggest me a way with which I can confirm on Solaris or otherwise what the endline character is 'LF' or 'CRLF'? Because I only have vi on Solaris and it does not show the endline characters. Also the Standard winscp text editor also does not show the new line characters. – ITguy Sep 25 '17 at 09:03
  • 1
    I found a way of checking if the files end with LF. Simply copy the file from Solaris to Windows as a binary. Then it will show LF where relevant. – ITguy Sep 25 '17 at 09:19
  • From my experience, if a lines ends with CRLF, the vi displays it with something like ^M. – chingNotCHing Sep 25 '17 at 09:19
2

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 tuned off, you will get file opened in Notepad++ exactly as it is stored on the server.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
-1

There are some options. You could setup Notepad++ to create Unix style text files. Another option is to setup scp so that it transfer in text mode the text file. The third option, however it may be some inconvenient to run every time - dos2unix command does exactly what you need The fourth option is to use vi or some editor in the Unix terminal. I think there is no need to do scripting for that.

Krassi Em
  • 182
  • 8