In a shell script I’m looking to iterate over an array like I would in python by doing:
for i, j in (("i value", "j value"), ("Another I value", "another j value")):
# Do stuff with i and j
print i, j
But can’t work out the best way to do it? I’m tempted to rewrite the shell script in python but that seems awfully heavy for what I’m trying to do.
In this instance I would do:
Note that each time you reference variables (
$1,$PATH, and especially$@, you want to surround them with""quotes – that way you avoid issues when there are spaces in the values.