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
current CPU usage, memory usage, disk I/O oid(snmp) S_venkatesh SUN Solaris 2 12-13-2008 06:19 AM
how can I find cpu usage memory usage swap usage and logical volume usage alert0919 HP-UX 3 12-02-2008 02:38 PM
problem with underscore in variable name pinkie UNIX for Dummies Questions & Answers 3 04-07-2008 09:27 AM
CPU usage and memory usage mansoorulhaq High Level Programming 1 08-09-2007 05:55 PM
Monitor CPU usage and Memory Usage Gajanad Bihani High Level Programming 2 03-09-2005 07:35 AM

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 12-08-2008
ahmedwaseem2000 ahmedwaseem2000 is offline
Registered User
  
 

Join Date: Aug 2005
Location: Bangalore
Posts: 219
usage of underscore in awk

Hi what is the purpose of using underscore in awk. I suppose it is for defining macro's and reducing repeatation but can some one show me an example?
  #2 (permalink)  
Old 12-08-2008
radoulov's Avatar
radoulov radoulov is offline Forum Staff  
addict
  
 

Join Date: Jan 2007
Location: Варна, България / Milano, Italia
Posts: 2,926
Could you give an example? I suppose it's a simple variable name without any special meaning (not like in Perl, for example).
  #3 (permalink)  
Old 12-08-2008
ahmedwaseem2000 ahmedwaseem2000 is offline
Registered User
  
 

Join Date: Aug 2005
Location: Bangalore
Posts: 219
here is the example i found in one of the posts and there are many more similar posts.


Code:
awk -v ID=$ID '$NF==ID{_=1} !NF && _{exit}_'  file > request_id_data.txt

  #4 (permalink)  
Old 12-08-2008
radoulov's Avatar
radoulov radoulov is offline Forum Staff  
addict
  
 

Join Date: Jan 2007
Location: Варна, България / Milano, Italia
Posts: 2,926
It's an ordinary AWK variable, it's the same as:


Code:
awk -v ID=$ID '$NF==ID{myvar=1} !NF && myvar{exit}myvar'

As far as my posts are concerned (the above is not mine, it's from danmero's post I think), it's just an attempt to make a boring code look nicer (like Apollinaire's poetry).

Last edited by radoulov; 12-08-2008 at 07:16 AM..
  #5 (permalink)  
Old 12-08-2008
ahmedwaseem2000 ahmedwaseem2000 is offline
Registered User
  
 

Join Date: Aug 2005
Location: Bangalore
Posts: 219
Sorry Its not a relevant question. I have gone a bit lousy to read the posts properly.

Last edited by ahmedwaseem2000; 12-08-2008 at 07:09 AM..
  #6 (permalink)  
Old 12-08-2008
radoulov's Avatar
radoulov radoulov is offline Forum Staff  
addict
  
 

Join Date: Jan 2007
Location: Варна, България / Milano, Italia
Posts: 2,926
1 or 0 (true or false in boolean context) as far as the above example is concerned.
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: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