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.
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.
In our previous post,
must use subscript when assigning associative array. The documentation mention clearly the requirement for the subscript part of the declaration.
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.
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.