T
T
Thomas Storm2015-08-31 11:30:58
bash
Thomas Storm, 2015-08-31 11:30:58

How to execute all elements of an array except one in bash, but work out this element in its own way?

Hello!
There is a file with arrays inside. Arrays look like:

declare -A codedep

codedep[array_name]="el1 el2 el3 el4 el5"

Next, we have a script that includes a file with an array inside:
#!/bin/bash
CODEPACK_0=$1 # Declare variable codepack name
. codepack_dependency # Include dependent codepack config file


# Triggering jobs for dependent codepacks
if [ "$CODEPACK_0" = "array_name" ] # check if used array_name, then echo elements

then
                        for i in ${codedep[$CODEPACK_0]}
                        do
                        echo $i
                        done
fi

In this case, I will display all the elements of the array.
Now let's imagine that I have an element (for example, el2) that should not be displayed or should be displayed as
echo "$i is a super element"
In other words, it is necessary to perform a separate operation with this element within the loop. What is the best way to do this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Saboteur, 2015-08-31
@v_sadist

At the beginning of the loop, check
if ; then
tralalal
continue
fi
Keyword - continue

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question