Skip to Content
Linux Command Line and Shell Scripting Techniques
book

Linux Command Line and Shell Scripting Techniques

by Vedran Dakic, Jasmin Redzepagic
March 2022
Beginner to intermediate
552 pages
11h 26m
English
Packt Publishing
Content preview from Linux Command Line and Shell Scripting Techniques

Chapter 12: Using Arguments and Functions

Whenever we are trying to program any kind of application or a script in any programming language, we should always try to make our code modular and easily maintainable. The thing that is going to help us a lot in this aspect of creating scripts is a concept known as a function.

We will cover the following recipes in this chapter:

  • Using custom functions in shell script code
  • Passing arguments to a function
  • Local and global variables
  • Working with returns from a function
  • Loading an external function to a shell script
  • Implementing commonly used procedures via functions

Technical requirements

For these recipes, we're going to use a Linux machine. We can use any virtual machine (VM) from our previous ...

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.
Start your free trial

You might also like

Mastering Linux Shell Scripting - Second Edition

Mastering Linux Shell Scripting - Second Edition

Mokhtar Ebrahim, Andrew Mallett
Linux Shell Scripting Cookbook - Third Edition

Linux Shell Scripting Cookbook - Third Edition

Clif Flynt, Sarath Lakshman, Shantanu Tushar

Publisher Resources

ISBN: 9781800205192