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
get current system date wtolentino UNIX for Dummies Questions & Answers 5 07-30-2009 10:55 AM
calculate the date of next satureday of current date. rinku Shell Programming and Scripting 3 09-02-2008 11:05 PM
Get date and time for past 1 hour from current date spch2o Shell Programming and Scripting 5 08-29-2008 04:32 AM
Perl: Extracting date from file name and comparing with current date MKNENI Shell Programming and Scripting 4 03-26-2008 04:01 PM
File date vs Current date trexlim Shell Programming and Scripting 4 05-04-2007 09:35 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-06-2008
wereyou wereyou is offline
Registered User
  
 

Join Date: Sep 2006
Posts: 19
Question Using awk and current date command

I am running a command to extract data from a database which has different text and dates (ex. 01/03/07, 05/29/08, 06/05/08). Once the file is created I need to grep for all the text with a current date then redirect the sorted data to another file then email the file out. Here is what I have right now. My question is how could I incorporate the date command to only output the current date automatically?

awk '{print $1 $2 $3 $4 $5}'|egrep 05/29/08 $MYHOME/all.sched > $MYHOME/all.scheda
more $MYHOME/all.scheda|mail -s "scheda" xxxxxx@xxxx.com < $MYHOME/all.scheda

OUTPUT:

servera schedule_1126 bob 05/29/08
serverb schedule_703 bob 05/29/08
serverc schedule_FRI2 mary 05/29/08
serverd schedule_FRI2 jane 05/29/08
  #2 (permalink)  
Old 06-06-2008
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,720
how about something like this:
Code:
awk -v mydate=$(date +%m/%d/%Y) '
        { if( index($0, mydate) > 0) 
              {print $1,$2,$3,$4,$5}
        }' | mail -s "scheda" xxxxxxxxxxx@xxx.com
  #3 (permalink)  
Old 06-06-2008
wereyou wereyou is offline
Registered User
  
 

Join Date: Sep 2006
Posts: 19
jim,

this worked. thanks for the help. i need to do some more tweaking to the script and i will post the results maybe sometime next week.

thanks again.
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 11:36 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