The UNIX and Linux Forums  


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
how to access values of awk/nawk variables outside the awk/nawk block? saniya Shell Programming and Scripting 5 05-13-2008 08:37 AM
I can't seem to pass variables properly into a nawk statement DeCoTwc Shell Programming and Scripting 6 03-30-2008 03:07 PM
nawk -v to awk kamel.seg Shell Programming and Scripting 2 12-18-2007 07:30 AM
nawk - Passing variables sharif Shell Programming and Scripting 3 08-14-2007 06:37 AM
Assigning nawk output to variables steveje0711 Shell Programming and Scripting 6 08-19-2005 06:03 PM

 
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
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 07-11-2005
plimpix plimpix is offline
Registered User
  
 

Join Date: May 2005
Location: Scotland
Posts: 28
nawk and variables

Hi guy's

Im trying to pass variables into nawk and then match them on a value within a record but it don't seem to be working. If i put in the dates i want to see then it works fine..

#!/usr/bin/ksh -x
YEST=$(/usr/local/bin/perl -e '@T=localtime(time-86400);printf("%02d/%02d/%02d\n",$T[4]+1,$T[3],($T[5]+1900)%100)')
DATE=$(date +%m/%d/%y)
MON=$(date +%m)
DAY=$(date +%d)
YEAR=$(date +%y)

bpdbjobs -report | /usr/bin/nawk -v DATE=$DATE -v YEST=$YEST '
{
if ( NF == 13 )
if ( $12 ~ /07\/09\/05/ || $12 ~ /07\/10\/05/ || $12 ~ /07\/11\/05/)
if ( $3 ~ /Done/ && $4 > 0 )
print

elseif ( NF == 12 )
if ( $11 ~ /07\/09\/05/ || $11 ~ /07\/10\/05/ || $11 ~ /07\/11\/05/)
if ( $3 ~ /Done/ && $4 > 0 )

print

}'

I want to have the following line looking like this and using the variable, if that makes sense


if ( $12 == YEST || $12 == DATE )

print


although this doesn't work how i would like i have even tried splitting up the %d / %m / %y but still no joy. Is some control symbol used to tell awk it is a variable with a value ?

Thanks in advance...

Kenny

Last edited by plimpix; 07-11-2005 at 12:33 PM..
 

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 07:49 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