![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
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 ) elseif ( NF == 12 ) if ( $11 ~ /07\/09\/05/ || $11 ~ /07\/10\/05/ || $11 ~ /07\/11\/05/) if ( $3 ~ /Done/ && $4 > 0 ) }' I want to have the following line looking like this and using the variable, if that makes sense if ( $12 == YEST || $12 == DATE ) 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 |
| Display Modes | Rate This Thread |
|
|