| new skills - Team Nuggets
New Training: Deploy and Execute Basic BASH Scripts
In this 10-video skill, CBT Nuggets trainer Shawn Powers teaches you how to create, deploy, and execute BASH scripts in a Linux environment. Learn how to specify your interpreter, how to reference a script within another script, how to add comments to your code, and how to create error messages that’ll properly display on STDERR. Gain an understanding of shell expansions, special variables, conditional statements (if-then), while loops, for loops, and more. Watch this new Linux training.
Learn Linux with one of these courses:
This training includes:
- 10 videos
- 57 minutes of training
You’ll learn these topics in this skill:
- Specifying the Interpreter in a Shell Script
- Sourcing Other Scripts Within a BASH Script
- Redirecting Errors
- Using Shell Expansions in a BASH Script Lab
- Understanding BASH Positional Parameters Lab
- Using Conditions (if/then)
- Getting Data into a Script
- Building While Loops and Until Loops in a BASH Script
- Using For Loops in a BASH Script
- Creating a Complex BASH Script Lab
Perform Repeated Operations With Bash Scripts And Loops
Loops are basic computer science principles taught in any introductory programming class. The idea of a loop is to perform a repeated task under certain conditions. While there are two primary types of loops (For Loops and While Loops), you'll need to understand the basic principles of loops before creating more complex tasks such as recursive operations. Why on earth do you need to understand how loops work for creating Bash scripts, though?
That's a complicated question to answer, and you'll need to understand the paradigms between Windows and Linux applications to answer that. In the world of Windows, larger, monolithic applications are designed to handle numerous, complex tasks. On the other hand, the world of Linux encourages creating small applications that perform extremely specific tasks.
Likewise, the preferred shell environment for Windows, Powershell, is capable of reading blobs of data as objects. Bash isn't able to do this. A blob of data is nothing more than a blob to Bash.
Because of this, it's very common for Bash scripts to loop through data. These small applications are typically designed to handle one input and output task in Linux. Bash scripts will need to loop through each blob of data, process it, and then start over with the next blob.
Understanding the principles of loops and these software paradigm differences is important for creating complex scripts for Bash. These principles will lead to things like creating complex data structures and recursive methods for handling and piping data in Linux.