![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
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 07:37 AM |
| Passing Vars between scripts | rcunn87 | Shell Programming and Scripting | 4 | 06-23-2006 06:07 AM |
| Can I export vars without polluting my namespace? | tphyahoo | Shell Programming and Scripting | 2 | 06-06-2006 11:03 AM |
| Env vars in a SED script | Bags | Shell Programming and Scripting | 8 | 05-12-2006 02:53 PM |
| need help with nawk using -v vars | amon | Shell Programming and Scripting | 3 | 01-26-2006 06:23 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
NEW: need help with nawk using -v vars
I'm trying to pass nawk a shell variable to be used in a pattern match. I can't get this work.
I'm calling nawk from a /bin/sh I want that when somebody enters Trunk Group in variable TGR so it goes into nawk variable TG. Code:
echo "Enter TRUNK GROUP:"
read TGR
cat /omp-data/logs/5etr/$SearchDate.APX | nawk -F"|" -v P=$TGR '
#cat /omp-data/logs/5etr/$SearchDate.APX
BEGIN {
TG=$P;
printf ("DATE IN ST EN TGN ISEIZE ISATMP IANS OATMPT OVFL OSEIZE OSATMP OANS TOTUSG OOSMTCE OOS DBLSZR NTWCONG\n");
}
THANKS in advance Last edited by Yogesh Sawant; 04-21-2008 at 04:19 AM.. Reason: added code tags |
|
||||
|
Can you please tell me that do i have to convert variable P into integer in BEGIN. Because now it is running but giving no output.
Actaually value of P should be like 700, 701, 744, 601 like this.. echo "Enter TRUNK GROUP:" read TGR cat | nawk -F"|" -v P=$TGR ' BEGIN { TG=P; printf ("DATE IN ST EN TGN ISEIZE ISATMP IANS OATMPT OVFL OSEIZE OSATMP OANS TOTUSG OOSMTCE OOS DBLSZR NTWCONG\n"); } . . . . . ' /omp-data/logs/5etr/$SearchDate.APX |
|
||||
|
I am trying to make a simple script in which i take input from shell and then forward the value to
nawk (BEGIN). but when i run below mention script so it give no output. Code:
Code:
echo "Enter TRUNK GROUP:"
read TGR
cat /omp-data/logs/5etr/080422.APX | nawk -F"|" -v P=$TGR '
BEGIN {
TG=P;
printf ("DATE IN ST EN TGN ISEIZE ISATMP IANS OATMPT OVFL OSEIZE OSATMP OANS TOTUSG OOSMTCE OOS DBLSZR NTWCONG\n");
}
But when i run below code , so its work fine. Code:
Code:
#echo "Enter TRUNK GROUP:"
#read TGR
#cat /omp-data/logs/5etr/080422.APX | nawk -F"|" -v P=$TGR '
cat /omp-data/logs/5etr/080422.APX | nawk'
BEGIN {
TG=700;
printf ("DATE IN ST EN TGN ISEIZE ISATMP IANS OATMPT OVFL OSEIZE OSATMP OANS TOTUSG OOSMTCE OOS DBLSZR NTWCONG\n");
}
Regards |
|
||||
|
Anybody Please Reply !!!!!!!!
ANYBODY PLEASE REPLY !!!!!!!!
Regards, Waqas Ahmed |
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|