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.QUE UE
object type: queue
entity: mqm
entity type: group
authority: allmqi dlt chg dsp clr
- - - - - - - -
profile: SYSTEM.CLUSTER.TRANSMIT.QU EUE
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.?
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.QUE
object type: queue
entity: mqm
entity type: group
authority: allmqi dlt chg dsp clr
- - - - - - - -
profile: SYSTEM.CLUSTER.TRANSMIT.QU
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
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
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
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
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
ASKER
can you modify to add the (and condition).