samedi 3 janvier 2015

How do I test if an item is in a bash array?


Help for a simple script



#!/bin/sh

array1=(
prova1
prova2
slack64
)

a="slack64"
b="ab"

if [ $a = $b ]
then
echo "$a = $b : a is equal to b"
else
echo "$a = $b: a is not equal to b"
fi




This script simply doesn't work, I want a script which check if slack64 is present in a list(i use an array),and simply give me, yes is present,or no. I don't know how to compare an array with a single variable.



Aucun commentaire:

Enregistrer un commentaire