Solved

unix scripting task

Posted on 2008-06-12
5
214 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Java performance on Solaris - Managing CPUs There are various resource controls in operating system which directly/indirectly influence the performance of application. one of the most important resource controls is "CPU".   In a multithreaded…
Recently, an awarded photographer, Selina De Maeyer (http://www.selinademaeyer.com/), completed a photo shoot of a beautiful event (http://www.sintjacobantwerpen.be/verslag-en-fotoreportage-van-de-sacramentsprocessie-door-antwerpen#thumbnails) in An…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
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…

762 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

23 Experts available now in Live!

Get 1:1 Help Now