Skip to content
Advertisement

Arrays in Shell Script, not Bash

I am probably just having a brain fart, but I can not for the life of me figure out how to loop through an array in shell script, not bash. Im sure the answer is on stackoverflow somewhere already, but I can not find a method of doing so without using bash. For my embedded target system bash is not currently an option. Here is an example of what I am attempting to do and the error that is returned.

JavaScript

Whenever I run this script the error “Bad substitution” is returned for line with the if statement. If you guys have any ideas I would greatly appreciate it. Thanks!

Advertisement

Answer

BusyBox provides ash which does not directly provide array support. You could use eval and something like,

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement