0

I have an SMB connection to an Ubuntu Server 12.10 host that has shell scripts and config files I want to edit with a Windows 7 client using Notepad++. I am able to open the files and make changes, but as soon as I save them, with no changes to the character encoding, they become unreadable on the host.

How can I edit and save the files in Windows 7 so they can be read and executed in Ubuntu Server 12.10?

3
  • What does 'unreadable' mean?
    – terdon
    Commented Jan 16, 2013 at 15:18
  • @terdon It means the Tomcat server using the config files stops working.
    – Keyslinger
    Commented Jan 16, 2013 at 15:25
  • OK, see Jim's answer then. Or mine.
    – terdon
    Commented Jan 16, 2013 at 15:26

2 Answers 2

4

EDIT: You can enable Unix line termination in Notepad++ in Edit -> EOL Conversion -> Unix Format.

One of the most common problems with text file compatibility between Unix and Windows systems is that Windows' notion of line termination is CRLF (carriage-return + linefeed, ascii 13 and 10), while Unix uses just LF (10). This is probably getting you an error like ./foo.sh: bad interpreter: /bin/sh^M: no such file or directory.

There's a utility called dos2unix that will convert any existing files for you, on the Ubuntu side:

apt-get install dos2unix
dos2unix myscript.sh

That modifies the file in-place to strip out the CRs.

0

As Jim said, the problem is probably line termination. You can fix this on the Linux server by running this command on your modified files:

sed -i 'N;s/\r\n/\n/g' file
2
  • Jim's response helped me, but I'll keep this in mind in case I ever find myself without access to either of the solutions he gave me.
    – Keyslinger
    Commented Jan 16, 2013 at 15:40
  • Just to clarify, he gave you one solution. The first command just installs the necessary program, you will only need to run it once.
    – terdon
    Commented Jan 16, 2013 at 15:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .