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
AWK (NAWK) and filtering values Nicol UNIX for Dummies Questions & Answers 11 04-23-2008 05:40 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
awk/nawk returning decimal values? moutaye Shell Programming and Scripting 1 03-25-2008 03:04 PM
awk/nawk returning decimal values? moutaye SUN Solaris 1 03-25-2008 03:02 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 02-02-2006
swamymns swamymns is offline
Registered User
  
 

Join Date: Sep 2005
Posts: 25
is it possible to pass external variable values to nawk?

Dear friends,
please tell me how to pass the external variable values to the nawk command.

length=`expr $len2 - $len1`

i need to pass $length to following nawk command as mentioned below.

nawk '{if((x=index($0,"W/X"))>0){id=substr($0,x, $length);print x;print id;}}' filename1

but I am getting follwing error,
nawk: illegal field $()
input record number 1, file filename1
source line number 1

please tell me how to pass the $length value to the nawk .


waiting for ur reeply....

swamymns
  #2 (permalink)  
Old 02-02-2006
mahendramahendr mahendramahendr is offline Forum Advisor  
Registered User
  
 

Join Date: Dec 2005
Location: London
Posts: 222
here is a simple example :

$ nawk '{ print lngth }' lngth="5" file1
5
5
5
5
5
5

you can assign the shell variable nawk variable and then use the nawk variable inside the nawk script.
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 12:14 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