Bash Scripting - Bash Loops with examples

Bash Loops with examples

Ready to dive into Bash looping? With the popularity of Linux as a free operating system, and armed with the power of the Bash command line interface, one can go further still, coding advanced loops right from the command line, or within Bash scripts.

Harnessing this power, one can manipulate any document, any set of files, or implement advanced algorithms of almost any type and flavor. You are unlikely to run into any limitations if you use Bash as the basis for your scripting, and Bash loops form a powerful part of this.

That said, Bash loops sometimes can be tricky in terms of syntax and surrounding knowledge is paramount. Today we present with you a set of bash loop examples to help you upskill quickly and become Bash loop proficient! Let’s get started!

In this tutorial you will learn:

  • How Bash for, while and until based loops work, with examples
  • How Bash requires terminating of loop-starting statements before the do…done section of the loop can follow, and how this relates to if and other statements
  • How to implement basic and medium advanced bash loops
  • How subshells work and how they can be used inside bash loop scope declarations
  • How to start coding loops defensively, avoiding errors in the output
  • How to code one-liners (a common term used amongst Bash developers) on the command line versus implement the same code in a Bash script
  • How the ; syntax idiom is an important matter when it comes to coding Bash loops, both on the command line and in scripts

Read more

Python Regular Expressions with Examples

Python Regular Expressions with Examples

A regular expression (often abbreviated to “regex”) is a technique, and a textual pattern, which defines how one wants to search or modify a given string. Regular expressions are commonly used in Bash shell scripts and in Python code, as well as in various other programming languages.

In this tutorial you will learn:

  • How to start with Regular Expressions on Python
  • How to import regex Python module
  • How to match strings and characters using Regex notation
  • How to use the most common Python Regex notations

Read more