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
NEW: need help with nawk using -v vars wakhan Shell Programming and Scripting 20 04-26-2008 05:44 AM
Passing Vars between scripts rcunn87 Shell Programming and Scripting 4 06-23-2006 07:07 AM
Can I export vars without polluting my namespace? tphyahoo Shell Programming and Scripting 2 06-06-2006 12:03 PM
Env vars in a SED script Bags Shell Programming and Scripting 8 05-12-2006 03:53 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 01-23-2006
amon amon is offline
Registered User
  
 

Join Date: Jan 2006
Posts: 71
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

echo " Input file: \c"
read var1
echo " Input: \c"
read var2

nawk -F"|" -v x=$1 ' BEGIN
$15 ~ /^'$var2'/ {print $2}' var1 {apary=$15; bparty=$23; time=$4; duration=$43; account=$65; charge=$66}
END { print apary"|"bparty"|"vrijeme"|"duration"|"account"|"charge } ' $1 >> final


so I should read from file var1 and search for pattern var2 and put all that in file final.

PLEASE can anyone help me out with this code somehow it does not work..

THANKS in advance
 

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 08:32 AM.


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