I have an array created and I want to look for a keyword and then if found, display the element that is n elements behind it. Is that possible to do with bash and if so, could someone provide an example? Example of operation:
element 1=red
element 2=blue
element 3=green
Parse through the array and if you see "green", display the element that is 2 behind it. In this case, it would return "red".