Variable and Argument Questions

This section examines some questions that relate to variables and their use in shell scripts. It also covers questions related to command-line arguments.

How can I include functions and variable definitions located in one script in to another script?

To include functions and variable definitions defined in one script in to another script, you need to use the . command as follows:

. file
						

Here file is the pathname of the script you want to include. This topic is covered in detail in Chapter 21, “Problem Solving with Functions.”

When you include a file using the . command, make sure that the file does not contain ...

Get Sams Teach Yourself Shell Programming in 24 Hours, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.