Different end of line characters in text files

The PC environment and the z/OS® UNIX environment normally use different end of line characters in text files. The end of line characters are placed into the file as the text lines are written by the application (for example, an editor) based on the environment the application is running on (Windows versus z/OS UNIX). If you are sharing text files between the PC environment and the z/OS UNIX environment, one of the environments sees end of line characters at the end of each line of text that it does not normally expect. Some applications might not process a text file if the wrong end of line characters are in the text file. For example, the C/C++ compiler does not compile source code with PC end of line characters. You should try to use applications on the PC that support z/OS UNIX end of line characters. Microsoft WordPad correctly displays text files that have z/OS UNIX end of line characters. However, when the file is saved, the end of line characters are changed to Windows end of line characters. There are also PC applications that optionally create a text file with z/OS UNIX end of line characters. An example of an application that creates a text file with z/OS UNIX end of line characters is MicroEdge Visual SlickEdit. Many PC applications tolerate z/OS UNIX end of line characters.

To determine which end of line characters are contained in a text file, you can use the following z/OS UNIX command to display the hexadecimal values of the characters in a file, where textfile.txt is the name of the text file you want to display.

od -cx textfile.txt

When a text file has PC end of line characters, you can create another file with the same data but with z/OS UNIX end of line characters. To do so, issue the following z/OS UNIX command, where textfile.txt is the text file with PC end of line characters and newfile.txt is a new text file with z/OS UNIX end of line characters.

tr -d '\r' <textfile.txt >newfile.txt

In general, z/OS UNIX text files contain a newline character at the end of each line. In ASCII, newline is X'0A'. In EBCDIC, newline is X'15'. (For example, ASCII code page ISO8859-1 and EBCDIC code page IBM-1047 translate back and forth between these characters.) Windows programs normally use a carriage return followed by a line feed character at the end of each line of a text file. In ASCII, carriage return/line feed is X'0D'/X'0A'. In EBCDIC, carriage return/line feed is X'0D'/X'15'. The tr command shown in the preceding example deletes all of the carriage return characters. (Line feed and newline characters have the same hexadecimal value.) The SMB server can translate end of line characters from ASCII to EBCDIC and back but it does not change the type of delimiter (PC versus z/OS UNIX) nor the number of characters in the file.