Grepping for a fixture ID and printing the 2 teams involved

Hello, I have a fixture file which looks something like the attached.

At the top of each file is a list of teams who are involved in at least one of the fixture below.

I currently have a grep which searches in each clients fixture file to confirm whether or not they have received a specific fixture ID. What I would like to do is be able to grep for a fixture ID and print an output something like;

Fixture ID: xxxxxxx
Team1 vs Team2

Clients;
client1
client2
client3
etc

At the moment all I get is;

Fixture ID: xxxxxxx

Clients;
client1
client2
client3
etc

What would be the best way of printing the related teams to the page too?
Fixture file;
 
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Fixtures SYSTEM "Fixtures.dtd">
<Fixtures sport="Soccer">
  <Teams>
    <Team id="65" name="Swansea" />
   <Team id="41" name="Watford" />
  <Fixture id="3072313" competitionId="301" stageNumber="1" roundNumber="5" leg="1" date="20081111" time="1945+0000" venue="Liberty Stadium" country="England
">
    <Participant teamId="65" />
    <Participant teamId="41" />
  </Fixture>
</Fixtures>
 
Script which runs the grep;
 
#!/bin/bash
echo
read -p "Enter the fixture id:" id
 
echo "These clients take fixture " $id
grep $id /usr/local/production/soccermatchplus/distributor/clients/*/out/fixtures.xml | awk -F/ '{print $8}'

Open in new window

LVL 7
dann47Asked:
Who is Participating?
 
mikelfritzConnect With a Mentor Commented:
you could try adding this just above your grep:

file=`grep -l $id /usr/local/production/soccermatchplus/distributor/clients/*/out/fixtures.xml`
cat $file | grep name | tail -2l | awk -F\" '{ print $4 }'
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.