Shell scripting libraries

To really take advantage of automating tasks using shell scripts, it's important to organize all common tasks into reusable commands and have them available in the path. To do this, it's a good idea to create a bin folder inside the home directory for the scripts, and a bin/lib directory for storing common pieces of code. When working with lots of shell scripts, it's important to reuse large pieces of functionality. This can be achieved by writing library functions for your shell scripts, functions that you can call from multiple places.

Here we will create a library script called util.sh, which will be sourced in other scripts. By sourcing the script, we get access to functions and variables from inside the library script. ...

Get Working with Linux – Quick Hacks for the Command Line 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.