Link to home
Create AccountLog in
Avatar of vishali_vishu
vishali_vishu

asked on

unix scripting task

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.?



ASKER CERTIFIED SOLUTION
Avatar of omarfarid
omarfarid
Flag of United Arab Emirates image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of vishali_vishu
vishali_vishu

ASKER

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

can you modify to add the (and condition).

Try:

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

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

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