extract using sed/awk - need help? Please!!

Need help..not sure how to use with awk or sed
I want to take data from the notification.$$ file and assign the data to variable "group". Not sure how to do it.

The data I want to extract from the notification.$$ is on the first line of the file ..right after the (notice):
NetWorker savegroup: (notice) EGL completed,

1 # This script sends email that save group completed.
2 #!/bin/sh
3 group=" "
4 dat=`date +"%c"`
5 log='/nsr/logs/test_savegrp.log'
6 echo "\n -- BUR Legato $dat Test Save Group Notification -- \n" >> $log
7 tee notification.$$ >> $log
8 group=`grep -l notice
9 echo " -- $dat end of $group Savegroup Message --\n" >> $log
10 awk "
11 /usr/ucb/mail -s "$dat $group-BUR Networker Savegroup Completion Report" xxx.email < notification.$$ >>
$log 2>&1
~
~

I figured this so far...

So how do I assign the print $4 to another variable that I can save within the script.

egrep notice 20071008_1105_savegroup.txt | awk '{print $4}'; grp="$4"; echo $grp
EGL-Rerun

do this

grp=`grep notice 20071008_1105_savegroup.txt | awk '{print $4}'`
or
grp =`grep notice 20071008_1105_savegroup.txt | cut -d'delimeter' -f4`
or
grp =`awk '/notice/{print $4}'`

cheers,
Devaraj Takhellambam

But It still will not pass my $4 to where I need to print it. How can I assign that $4 to a variable to save.

1 # This script sends email that save group completed.
2 #!/bin/sh
3 dat=`date +"%c"`
4 log='/nsr/logs/savegrp.log'
5 echo "\n -- $4 BUR Legato $dat Save Group Notification -- \n" >> $log
6 tee -a notification.$$ >> $log
7 grep notice notification.$$
8 awk '{print $4}'
9 grp=`awk '{print $4}`
10 echo " -- end of $grp Savegroup Message --\n" >>$log
11 sudo /usr/ucb/mail -s "$dat $4 Networker Savegroup Completion Report" mailxxx.com < notification.$$ >> $
log 2>&1

1 # This script sends email that save group completed.
2 #!/bin/sh
3 dat=`date +"%c"`
4 log='/nsr/logs/savegrp.log'
5 echo "\n -- $4 BUR Legato $dat Save Group Notification -- \n" >> $log
6 tee -a notification.$$ >> $log
7 grep notice notification.$$
8 awk '/notice/{print $4}' notification.$$
9 grp =`awk '/notice/{print $4}' notification.$$ `
10 echo " -- end of $grp Savegroup Message --\n" >>$log
11 sudo /usr/ucb/mail -s "$dat $grp Networker Savegroup Completion Report" mailxxx.com < notification.$$ >> $
log 2>&1

cheers,
Devaraj Takhellambam

Thank-you so much for your help. That worked. :slight_smile: