grep words from output file

Hi,

By using shell scripit i have save output in one file. I want to grep two words named CLUSTER and CLUSQMGR from that output file. How to grep that. output file would be having below words

 
   TYPE(QCLUSTER)                          ALTDATE(2010-05-17)
   CLUSTER(QS.CL.MFT1)                 CLUSQMGR(QS.QM.BALT1)
 

from above file i want to get CLUSTER and CLUSQMGR only and then i want to do below syntax.

dis $CLUSQMGR $CLUSTER channel

it shoudl work like below

dis CLUSQMGR(QS.QM.BALT1) CLUSTER(QS.CL.MFT1) channel

Where does grep go? It is a shell/sed/awk/PERL problem!

 
sed '
  s/.*\(CLUSTER([^)]*\)).*\(CLUSQMGR([^)]*\).*/dis \2 \1 channel'
  t
  d
 ' your_file | ksh

Hi Pickett,

it is little confusing and i didn't get my out put with it.

Maybe it deleted all the lines because they do not look like that? Or minor typo or two:

echo '
   TYPE(QCLUSTER)                          ALTDATE(2010-05-17)
   CLUSTER(QS.CL.MFT1)                 CLUSQMGR(QS.QM.BALT1)
' | sed '
  s/.*\(CLUSTER([^)]*)\).*\(CLUSQMGR([^)]*)\).*/dis \2 \1 channel/
  t
  d
 '
dis CLUSQMGR(QS.QM.BALT1) CLUSTER(QS.CL.MFT1) channel

You mean that you have a script called "dis", that you want to call with two arguments, and have them extract the information?

$ cat dis
A=${1:-CLUSTER}
B=${2:-CLUSQMGR}

sed -n "s/.*\($A([^)]*)\).*\($B([^)]*)\).*/dis \2 \1 channel/p" file1

Output:

dis CLUSQMGR(QS.QM.BALT1) CLUSTER(QS.CL.MFT1) channel

@scottn:

I have output.txt. that file is like below

TYPE(QCLUSTER) ALTDATE(2010-05-17)
CLUSTER(QS.CL.MFT1) CLUSQMGR(QS.QM.BALT1)

I want only CLUSQMGR and CLUSTER only.I want to perform the command with help of output.txt.
Commans should be
dis CLUSQMGR(QS.QM.BALT1) CLUSTER(QS.CL.MFT1) channel.

Suggest me what i need to do?