?
Solved

Grepping for a fixture ID and printing the 2 teams involved

Posted on 2008-11-13
1
Medium Priority
?
312 Views
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

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

0
Comment
Question by:dann47
1 Comment
 
LVL 14

Accepted Solution

by:
mikelfritz earned 1500 total points
ID: 22980527
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

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses

864 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