Grep for a particular word and get only the word

HI,

Let us a consider i have a file as following.

abcde (flag5 / 234 ) Mod 45 efgh
afghd (flag3/ 343) MOD 34 ghdd
tryd (t_flag6/ 567 ) MOD 43 uifudiu

Is there a way where I need only the flag and the calculation done on it.
The output should be :

(flag5 / 234 ) Mod 45 
(flag3/ 343) MOD 34 
(t_flag6/ 567 ) MOD 43

With grep..

grep -o '(.* ' inputfile > outfile
echo "abcde (flag5 / 234 ) Mod 45 efgh
afghd (flag3/ 343) MOD 34 ghdd
tryd (t_flag6/ 567 ) MOD 43 uifudiu" |grep -o "(.*[0-9]"
(flag5 / 234 ) Mod 45
(flag3/ 343) MOD 34
(t_flag6/ 567 ) MOD 43

Hi ,

When i run it i am getting the following error...

Probably mine is a different version from yours .Mine is Sun Os 5.1

how about this?

 echo "abcde (flag5 / 234 ) Mod 45 efgh
afghd (flag3/ 343) MOD 34 ghdd
tryd (t_flag6/ 567 ) MOD 43 uifudiu" |gawk '{print gensub(/.* (\(.*[0-9]) .*/,"\\1",1,$0)}'
(flag5 / 234 ) Mod 45
(flag3/ 343) MOD 34
(t_flag6/ 567 ) MOD 43

HI ,

Guess even gawk is not supported.

I m getting the following error.

-bash: gawk: command not found
 echo "abcde (flag5 / 234 ) Mod 45 efgh
afghd (flag3/ 343) MOD 34 ghdd
tryd (t_flag6/ 567 ) MOD 43 uifudiu" |sed 's/.* \((.*[0-9]\) .*/\1/'
(flag5 / 234 ) Mod 45
(flag3/ 343) MOD 34
(t_flag6/ 567 ) MOD 43

Hi ,

Can you explain how the command works.. I want to check different scenarios.

In Solaris nwak should be used instead of [g]awk.