O'Reilly logo

Linux and Unix Shell Programming by David Tansley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

19.3. Passing parameters to a function

Parameters are passed to function just like in a normal script using the special variables $1, $2... $9. When the function gets arguments passed to it, it will replace the arguments originally passed to the shell script, if any, so it’s always a good idea to reassign the variables when the function gets them. This is a good idea anyway; if there are any bugs in the function, they can quickly be tracked down by the localized variable names. The convention for calling arguments (variables) inside a function is to start each variable name with a underscore (_), like this: _FILENAME or _filename.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required