jeudi 28 avril 2016

Match List of Numbers in For Loop in Bash

I have a script that loops over a curl command, which pulls in data from an API.

LIST_OF_ID=$(curl -s -X POST -d "username=$USER&password=$PASS&action=action" http://link.to/api.php)

for PHONE_NUMBER in $(echo $LIST_OF_ID | tr '_' ' ' | awk '{print $2}');
do
  $VOIP_ID = $(echo $LIST_OF_ID | tr '_' ' ' | awk '{print $1}')
done

I also have a variable of 16 numbers in the range of "447856321455"

NUMBERS=$(cat << EOF
441111111111
441111111112
441111111113
... etc
)

The output on the API call is:

652364_441111111112

As you may notice I have taken the output and cut it into 2 parts and put it in a variable.

What I need is to match the 6 digit code from the output where the number in the output, matches with the number in the variable.

I've attempted it using if statements but I can't work my head around the correct way of doing it.

Any help would be appreciated.

Thank you.

Aucun commentaire:

Enregistrer un commentaire