Unix Tip: Managing line termination differences in text files
By Sandra Henry-Stocker
Most every Unix sysadmin has run smack into line ending incompatibilities from time to time. The most common problem is the appearance of ^M characters at the ends of lines in text files that were built for or on Windows systems. Text files often end up with the pesky ^M characters when they're transferred from one system to another using scp or ftp in binary (byte-by-byte) mode instead of ASCII mode.
For many applications, the extra ^M characters cause no problems whatsoever. If you have a configuration file that includes these characters, the software that reads the file may not notice or balk. The ^M characters at the end of shebang lines, on the other hand, can confuse Unix systems. The string #!/bin/bash^M, after all, doesn't exactly match what the system needs to identify /bin/bash as the appropriate shell to process the file's contents. Try to execute a script that looks like this in vi and you'll end up with a "./shoplist: No such file or directory" error:
Read the full article here
Most every Unix sysadmin has run smack into line ending incompatibilities from time to time. The most common problem is the appearance of ^M characters at the ends of lines in text files that were built for or on Windows systems. Text files often end up with the pesky ^M characters when they're transferred from one system to another using scp or ftp in binary (byte-by-byte) mode instead of ASCII mode.
For many applications, the extra ^M characters cause no problems whatsoever. If you have a configuration file that includes these characters, the software that reads the file may not notice or balk. The ^M characters at the end of shebang lines, on the other hand, can confuse Unix systems. The string #!/bin/bash^M, after all, doesn't exactly match what the system needs to identify /bin/bash as the appropriate shell to process the file's contents. Try to execute a script that looks like this in vi and you'll end up with a "./shoplist: No such file or directory" error:
Read the full article here
0 Comments:
Post a Comment
<< Home