Unix shell script – convert Mac ASCII file to Unix ASCII file

With some applications like Microsoft Word you can save a file in ASCII format. However, for new lines Macs use a carriage return (ASCII character 015) while Unix uses a linefeed (ASCII character 012). If you save the file as ASCII on a Mac and open the file up in Unix it will look like one very long paragraph. Just to be complete, I will mention that Microsoft Windows uses a carriage return + linefeed combination between lines of text. Below is a shell script that will take a number of file inputs in Unix and convert the Mac files to the correct Unix format. The original file will be overwritten. At the command prompt you would enter the command as “mactounix [macfile 1] [macfile 2] [macfile 3]” etc… The is assuming you save the code to a file called mactounix and made it executable (chmod +x mactounix).

Shell script to convert Mac ASCII file to Unix ASCII file

This entry was posted in Linux, Operating Systems, Programming Languages, Shell Scripts and tagged , , , , , , , , , . Bookmark the permalink.

1 Response to Unix shell script – convert Mac ASCII file to Unix ASCII file

  1. Pingback: Humair’s Blogs » Blog Archive » Perl – Changing the Input Line Separator and Using the “Chomp” Function

Leave a Reply

Your email address will not be published. Required fields are marked *


− three = 4