Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google site



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Reply
English Japanese Spanish French German Portuguese Italian Powered by Powered by Google
 
Thread Tools Search this Thread Rate Thread Display Modes
  #15 (permalink)  
Old 11-18-2009
Registered User
 

Join Date: Mar 2009
Posts: 163
Still the same error.
Anyways with out it (\)the script working great. Thank you.
Still I have not cleared the doubts about previous scripts(awk one liners). Whats wrong with the previous scripts?
Sponsored Links
  #16 (permalink)  
Old 11-18-2009
danmero danmero is offline Forum Advisor  
 

Join Date: Nov 2007
Location: H3X
Posts: 1,566
Quote:
Originally Posted by repinementer View Post
Still the same error.
Anyways with out it (\)the script working great. Thank you.
My awk(FreeBSD) require (\) backslash

Quote:
Originally Posted by repinementer View Post
Still I have not cleared the doubts about previous scripts(awk one liners). Whats wrong with the previous scripts?
Quote:
Code:
awk 'NR==FNR{a[$1]=$2;next} a[$1] && ($2 <= a[$1]+1000) && ($2 >= a[$1]-1000) {print a[$1], $0}' test1.txt test2.txt

Using the first column value as array key to hold the second column value, because you have multiple records having the same key value (x1 and x2 in this example) each one will overwrite the previous one and only the last one will be saved in array as per your example:
Quote:
Code:
x1    10
x1    100
x2    1000
x2    10000
x3    989
x4    345
x10    8767736477736
xx    234
xy    387889999

  #17 (permalink)  
Old 11-18-2009
Registered User
 

Join Date: Mar 2009
Posts: 163
That make sense. Thanx alot for cooperation.
Sponsored Links
Reply

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 Off


More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to pick values from column based on key values by usin AWK repinementer Shell Programming and Scripting 16 07-24-2009 09:59 AM
Converting Binary decimal coded values to Ascii Values gaur.deepti UNIX for Advanced & Expert Users 3 04-02-2008 01:33 PM
Sunblade 1000 Kawakaze UNIX for Dummies Questions & Answers 3 03-16-2008 06:32 AM
Can I use both of TCP/IP 10/100 and 100/1000? trantuananh24hg Solaris 10 12-28-2007 05:52 AM
Help me spend $1000 John Bruzzese UNIX for Dummies Questions & Answers 1 12-07-2005 01:14 AM



All times are GMT -4. The time now is 08:55 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-2010. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0