Grepping for a fixture ID and printing the 2 teams involved

Posted on 2008-11-13
Last Modified: 2013-12-26
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


At the moment all I get is;

Fixture ID: xxxxxxx


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">


    <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" />



Script which runs the grep;



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

Question by:dann47
    1 Comment
    LVL 14

    Accepted Solution

    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 }'

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
    I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
    Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now