Today I Learned: collection of notes, tips and tricks and stuff I learn from day to day working with computers and technology as an open source contributor and product manager

View project on GitHub

Use bash

These might need to be broken into separate TILs for ease of navigation

A good cheat sheet can be found in this blog post

Find Substrings in Bash

https://linuxize.com/post/how-to-check-if-string-contains-substring-in-bash/ https://www.baeldung.com/linux/string-contains-substring



error conditional binary operator expected in compound branch


Split Strings


Use Booleans

How can I declare and use Boolean variables in a shell script?

Bash if, then, else


Handle empty element in array


Syntax error: redirection unexpected

If you observe the following error

Syntax error: redirection unexpected

It is due to your Bash script is being executing by a non-bash interpreter, e.g. sh or similar.

You might have specified the shebang line in your shell script file:


But if it is executed as:

sh myscript.sh

The shebang line is overridden by the interpreter specified on the command line.

I observed this issue in a Dockerfile, where the entrypoint was specified as:

ENTRYPOINT ["/bin/sh", "/entrypoint.sh"]

So when I introduced more Bash in my entrypoint.sh I was doomed. Changing the interpreter in the Dockerfile fixed the issue.

ENTRYPOINT ["/bin/bash", "/entrypoint.sh"]

Answer lifted from StackOverflow example lifted from rojopolis/spellcheck-github-actions. Do also see the reference Docker documentation