Whispers & Screams
And Other Things

Passing Dynamic Arguments to Bash Scripts


It is possible to pass arguments to a bash script when it is called from the command line. This is the technique to use when you need to have your script carry out different actions each time it runs dependent on the input and the context. This is done by passing selected parameters to the file on the command line and these parameters are called arguments.

Lets look at an example, you may have a script called "graph.sh" that performs a particular operation on an RRD file, such as extracting the data. If you want to be able to use that script on many RRD files in many different user directories, it is best to pass the file path as an argument, so that you can use the same script for all the files to be processed.

Continue reading
1346 Hits
0 Comments