Archive for the ‘Shell Scripts’ Category

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

Sunday, July 10th, 2011

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). (more…)

Twitt