Great question — answering as the UphillTech team:
This definitely seems like an x-y problem . It would help to know what the ultimate end goal for this is, but: Your variable var is actually an array because of the var=( ... ) syntax Because you quote everything in the parenthesis you are adding all data to a single element You are not using the proper syntax to call an array ( ${var[@]} ) which in this example isn't a big deal since everything is in a single element anyway The biggest problem seems to be the way the logical AND gets quoted and interpreted. If you don't quote it when adding to the array the shell will attempt to evaluate it, and if you do quote it, it will remain a literal string preventing evaluation. One of the ways I...
Full answer by jesse_b: https://unix.stackexchange.com/a/518413 (CC BY-SA 4.0).
Need it done for your business? UphillTech.