Go Back   The UNIX and Linux Forums > Top Forums > Emergency UNIX and Linux Support !! Help Me!!
google site



Emergency UNIX and Linux Support !! Help Me!! Post your urgent questions here for highest visibility. Posting a new thread to this forum requires Bits. We monitor this forum to help people with emergencies, but we do not guarantee response time or answers. This forum is "best effort" only. Members who reply to posts here receive a bonus of 1000 Bits per reply.

Closed Thread
English Japanese Spanish French German Portuguese Italian Powered by Powered by Google
 
Thread Tools Search this Thread Display Modes
  #15  
Old 01-02-2010
Registered User
 

Join Date: May 2008
Location: Chennai
Posts: 48
Thanks: 0
Thanked 0 Times in 0 Posts

Code:
#!/usr/bin/awk

BEGIN {
   col3[""]=0;
   col4[""]=0;
}

{
   if(col3[$3] <= 0){
       col3[$3] = 1;
       data3 = $3;
   }
   else {
      col3[$3]++;
      data3 = ($3-0.1*(col3[$3]-1)); 
   }

   if(col4[$4] <= 0) {
      col4[$4] = 1;
      data4 = $4;
   }
   else {
      col4[$4]++;
      data4 = ($4-0.1*(col4[$4]-1));
   }

   print $1 $2 data3 data4;

}

This is not tested..
Sponsored Links
  #16  
Old 01-03-2010
aaiaz's Avatar
Registered User
 

Join Date: Nov 2009
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
another approach:-


Code:
nawk 'a[$3$4]++ { $3 -= 0.1}1' test

but kindly radoulov in your solution

Code:
awk '($3 -= 0.1 * c[$3,$4]++)||1' infile

why you used multiplication instead of

Code:
awk '($3 -= 0.1 && c[$3,$4]++)||1' infile

  #17  
Old 01-03-2010
ahmad.diab's Avatar
Registered User
 

Join Date: May 2008
Location: Amman Jordan in MEA
Posts: 537
Thanks: 0
Thanked 1 Time in 1 Post

aaiaz:-

using multiplication and not && is for the subtraction value (amount) that we have to subtract after pattern repetition so you have to use
"*" not "&&"


by the way ...you code will not work proparly because each time you subtract
"0.1" although in the second pattern you have to subtract "0.2".

BR


  #18  
Old 01-03-2010
aaiaz's Avatar
Registered User
 

Join Date: Nov 2009
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks man for the details ...I had understand now.

Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Extract data based on match against one column data from a long list data patrick87 Shell Programming and Scripting 12 11-17-2009 03:27 AM
Linear data to column data..script help seeked ak835 Shell Programming and Scripting 1 09-02-2009 01:32 PM
How to check Null values in a file column by column if columns are Not NULLs Mandab Shell Programming and Scripting 7 03-15-2008 08:57 AM
check column ust Shell Programming and Scripting 1 01-24-2008 06:43 AM
How to check a column contain numeric or char data type ?? jambesh Shell Programming and Scripting 12 10-06-2006 10:37 AM



All times are GMT -4. The time now is 07:57 AM.