Tutorial: Windows vs. UNIX/Linux File Formatting Tips

For the most part, files generated in Windows will be compatible and readable on a UNIX/Linux system. One of the first key things for users to understand is that UNIX filenames are case-sensitive, while Windows filenames are not. So there is a difference between filename.txt and Filename.txt in UNIX. For this reason, I recommend leaving the CAPS LOCK key off for most activities on UNIX systems.

It is also important to remember that UNIX filesystems and many programming languages used in scientific computing will recognize a a filename containing a space, ” “, as delimiting between two filenames. If you do have a space in a filename, you will have to “escape” the space using the escape character preceding the space. The escape character is a backslash (\). For example, to edit a file named, “file name.txt“, you will have to type, “gedit file\ name.txt“. For this reason, it would be easier to try to remember to not include spaces in filenames. Use the underscore (_) character instead. This way, “file name.txt” would become, “file_name.txt“.

Most Windows files will work fine in most programs running on UNIX and Linux. However, if you are running a file through some software programs, you may encounter issues with differences in how Windows treats an end of line with some extra characters. These extra characters may cause errors in some programs. If you encounter this issue, you can run a simple awk command at the UNIX shell to handle this error:

awk ‘{ sub(“\r$”, “”); print }’ <filename>.sh > <filename>_n.sh

This will remove the end of line characters from the Windows file and create a new UNIX formatted file with a _n after the filename (the original file will be preserved.

This entry was posted in Tutorials. Bookmark the permalink.