как мне получить идентификатор устройства для определенного сетевого интерфейса?

Просто измените цикл for:

for index in ${array_item[*]}
    do
       check_$index
    done

Полный сценарий

#!/bin/bash

array_item=(item1 item2)

#function
check_item1 ()
{
   echo "hello from item1"
}
check_item2 ()
{
   echo "Hello from item2"
}   

for index in ${array_item[*]}
    do
       check_$index
    done

NB: Кроме того, доступны следующие фанковые конструкции:

${array_item[*]}         # All of the items in the array
${!array_item[*]}        # All of the indexes in the array
${#array_item[*]}        # Number of items in the array
${#array_item[0]}        # Length of item zero
1
07.08.2016, 15:53
0 ответов

Теги

Похожие вопросы