Shell
Running Bash script with Ubuntu on Windows 10 using WSL
Shell Tips
April 4, 2020 | COMMENTS

Windows 10 provide a neat integration with the Linux kernel which allows you to run any binary from your favorite linux distribution directly from Windows. This feature is called Windows Subsystem for Linux (WSL) and it opened a whole new world of opportunities.

Continue Reading
How To Parse a CSV File in Bash?
Shell Tips
March 16, 2020 | COMMENTS

Parsing a comma-separated values (CSV) file from the command line can be challenging and prone to errors depending on the complexity of the CSV file. Though, this is a frequent task in many automation scripts or to quickly process or reformat some imported files. In this post we will cover some of the common way to parse simple files with pure Bash or using AWK, and how to parse more complex CSV files.

Continue Reading
Bash Error: Must Use Subscript When Assigning Associative Array
Shell Tips
February 23, 2020 | COMMENTS

In our previous post, Iterate and Check if a Bash Array contains a value, we covered the different type of Bash Arrays available since Bash version >4. When using Associative Arrays, you may inadvertently improperly declare your Array and get the error must use subscript when assigning associative array. The documentation mention clearly the requirement for the subscript part of the declaration.

Continue Reading
Iterate and Check if a Bash Array contains a value
Shell Tips
January 27, 2020 | COMMENTS

Version 2 of GNU Bash added support for array variables, a.k.a one-dimensional indexed arrays (or lists). Since the version 4, came the support for associative arrays (a.k.a dictionaries or hashtables). Those features simplifies heavily how you can write your scripts and support more complex logics and use cases.

In this post we will review how to declare, iterate over, and check a value of an indexed arrays and associative arrays.

  1. Difference between Indexed Arrays and Associative Arrays
  2. How to declare a Bash Array
  3. Array Operations and How to loop over a Bash Array
  4. How to Check if a Bash Array contains a value
Continue Reading
How To Upgrade your Bash Version on MacOS
Shell Tips
January 16, 2020 | COMMENTS

GNU Bash is a powerful shell, unfortunately most distribution don't provide you with the latest version which may prevent you to take advantage of the great new features that came with Bash 4 and 5. Also, running an outdated bash version probably expose you to some major vulnerabilities. For example, MacOS comes with Bash 3.x which is quite limiting and lack key features like associative arrays (dictionnaries), improved auto-completion, better Posix conformance, etc. This post cover simple steps to upgrade bash on MacOS.

Continue Reading