The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
column extract help cvm Shell Programming and Scripting 1 04-24-2008 04:19 PM
How to extract the PID from 'ps -ef' nsinha Shell Programming and Scripting 7 11-20-2006 07:47 AM
Please help! Sed extract a pattern zhen Shell Programming and Scripting 11 09-18-2006 12:36 PM
tar. I can't extract volleyboy UNIX for Dummies Questions & Answers 1 02-17-2006 11:54 AM
extract from TAR big123456 UNIX for Advanced & Expert Users 8 07-28-2005 03:00 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-08-2007
gzs553 gzs553 is offline VIP Member  
Supporter
  
 

Join Date: Oct 2006
Posts: 42
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
~
~
  #2 (permalink)  
Old 10-08-2007
gzs553 gzs553 is offline VIP Member  
Supporter
  
 

Join Date: Oct 2006
Posts: 42
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
  #3 (permalink)  
Old 10-08-2007
devtakh devtakh is offline
Registered User
  
 

Join Date: Oct 2007
Location: Bangalore
Posts: 514
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
  #4 (permalink)  
Old 10-08-2007
gzs553 gzs553 is offline VIP Member  
Supporter
  
 

Join Date: Oct 2006
Posts: 42
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
  #5 (permalink)  
Old 10-08-2007
devtakh devtakh is offline
Registered User
  
 

Join Date: Oct 2007
Location: Bangalore
Posts: 514
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
  #6 (permalink)  
Old 10-08-2007
gzs553 gzs553 is offline VIP Member  
Supporter
  
 

Join Date: Oct 2006
Posts: 42
Thank-you so much for your help. That worked.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 09:35 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0