Posts Tagged ‘shell script’

BASH Shell Scripting: Passing Arguments to a Python Script

Monday, September 1st, 2014

Larry Wall: “Shell programming is a 1950s juke box …”

In this short blog I write a small Python utility script to create directories and demonstrate how to utilize it and pass it arguments via BASH shell script. The functionality is similar to the ‘mkdir’ UNIX command. The name of the directory or directories to be created is the argument I pass in to the Python script. I then create a BASH shell script to call the Python script. (more…)

Twitt

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