Solved

unix scripting task

Posted on 2008-06-12
5
217 Views
Last Modified: 2013-12-26
Hai !
       the task is as below.

i need to develop a shell script which reads a data file.

The data file looks like this:

profile:     SYSTEM.DEFAULT.MODEL.QUEUE
object type: queue
entity:      mqm
entity type: group
authority:   allmqi dlt chg dsp clr
- - - - - - - -
profile:     SYSTEM.ADMIN.CHANNEL.EVENT
object type: queue
entity:      mqm
entity type: group
authority:   allmqi dlt chg dsp clr
- - - - - - - -
profile:     SYSTEM.DEAD.LETTER.QUEUE
object type: queue
entity:      mqm
entity type: group
authority:   allmqi dlt chg dsp clr
- - - - - - - -
profile:     SYSTEM.CICS.INITIATION.QUEUE
object type: queue
entity:      mqm
entity type: group
authority:   allmqi dlt chg dsp clr
- - - - - - - -
profile:     SYSTEM.CLUSTER.TRANSMIT.QUEUE
object type: queue
entity:      mqm
entity type: group
authority:   allmqi dlt chg dsp clr
- - - - - - - -
profile:     TEST.A
object type: queue
entity:      lwcd
entity type: group
authority:   allmqi dlt chg dsp clr
---------------------------


The script should read profile and entity type  where entity is not mqm.

and display the profile and enitity type combinations on to screen.

How to do this.?



0
Comment
Question by:vishali_vishu
  • 2
  • 2
5 Comments
 
LVL 40

Accepted Solution

by:
omarfarid earned 500 total points
ID: 21771655
cat file | while read profile
do
   read l2
   read l3
   read l4
   read l5
   read l6
   set $l3
   if [ $2 != mqm ]
   then
         echo $profile
         echo $l3
   fi
done
0
 
LVL 1

Author Comment

by:vishali_vishu
ID: 21772088
excellent.... i want even to place the condition object type: queue  only to be selected .

can you modify to add the (and condition).
0
 
LVL 29

Expert Comment

by:MikeOM_DBA
ID: 21772724

Try:

awk -F: '/profile/ {printf "%s",$2;} /entity type/ {print $2;}' my_data
0
 
LVL 29

Expert Comment

by:MikeOM_DBA
ID: 21772821

Oooh, a condition?
OK:



awk -F: ' /profile/{p=$2}/object type/{o=$2}/entity type/{if (o==" queue") print p": "$2;}' my_data

Open in new window

0
 
LVL 40

Expert Comment

by:omarfarid
ID: 21772890
cat file | while read profile
do
   read l2
   read l3
   read l4
   read l5
   read l6
   set $l2
   obj=$2
   set $l3
   if [ $2 != mqm -a $obj = queue ]
   then
         echo $profile
         echo $l3
   fi
done
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Need to roll back kernel via script 4 85
Unix Script: Loop over all days of a month 17 105
IE 11 + long running scripts 3 74
Shell script issue 4 35
Let's say you need to move the data of a file system from one partition to another. This generally involves dismounting the file system, backing it up to tapes, and restoring it to a new partition. You may also copy the file system from one place to…
Background Still having to process all these year-end "csv" files received from all these sources (including Government entities), sometimes we have the need to examine the contents due to data error, etc... As a "Unix" shop, our only readily …
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

809 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