Functions
Functions are basically groups of statements that can be called with a single command. They can almost be thought of as “mini-programs inside programs.” Using functions in your shell programs can make your life a lot easier—for two reasons. First of all, if you need to perform the operation in multiple places in your program, you can simply type the name of the function rather than having to retype all the code each time you need to perform the operation. Second, if you later decide you need to make the operation work differently, you only have to change the function rather than go through the code and change it every place it is used. The following shows a simple example of a function that cleans up temp files, and so on, after a shell ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access