BASH Shell Scripting: Passing Arguments to a Python Script

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.

The BASH shell script file takes in a argument(s) and passes the argument(s) to the Python script file. I make the BASH script file an executable with the “chmod +x [BASH script name]” command; I can then put this small utility script in one my path directories as shown by the “echo $PATH” command and call it anytime as needed from the shell.

Python script code (

Python '' script code

Python '' script code

BASH shell script code (mkd):

BASH shell 'mkd' script code

BASH shell 'mkd' script code


Tags: , , , , , , , , , , , , , , , , , , , , , , ,

Leave a Reply


seven + 2 =