LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 03-27-2007, 07:45 AM   #1
vkmgeek
Member
 
Registered: Feb 2006
Location: Ahmedabad
Distribution: rhel5
Posts: 185
Blog Entries: 2

Rep: Reputation: 31
using awk


Hello,
I m confused a lil bit.

I am taking one variable in my script file which is an integer value.
Now, I want to use this value in awk command. How can I? Because when I take any variable in awk, it takes it as a local variable there only.

e.g,
I want to compare all emp's salary with some value.

awk -F":" '$2 > ValueToCompare {printf "%s \n",$0}' TCPCounterTemp.log > BumpingCounter.log;

This ValueToCompare I want to take as a variable which is declared outside awk. But I am not able to do it as I mentioned awk takes any variable as local there and initializes to zero.

Plllllease Helpppppppppp
 
Old 03-27-2007, 09:24 AM   #2
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
Read the "info gawk" manual. Section 6.2 is called "Using Shell Variables in Programs".
I would highly recommend installing the gawk source and using the "make pdf" target to produce the printable documentation "Gawk: Effective Awk Programming".
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Using awk vkmgeek Linux - General 2 03-14-2007 07:07 AM
awk kalyanofb Programming 4 02-19-2007 01:55 AM
Help with awk kshkid Programming 1 12-22-2006 05:59 AM
Do you know awk? Vitalka Linux - General 2 12-01-2006 11:53 PM
using awk meniscus Linux - Newbie 6 10-05-2006 12:39 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 03:19 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration