Sponsored Content
Top Forums Shell Programming and Scripting Comparing two files with numbers and taking difference in third file Post 302867101 by dev.devil.1983 on Wednesday 23rd of October 2013 11:44:58 AM
Old 10-23-2013
Thanks again Akshay!

The code seems to be working now when i am using 'nawk' instead of awk, the system as you correctly identified is solaris only ..

one last help that i would require is out of the output obtained in the previous post :

Code:
  2013  2013  
    Make200  Make201  
    Merc  BMW  
    Jpur  Del  
    PT  PT  
   Aug Aug  
G73 V_C A 2 7
G73 V_C B 2 7
G73 V_C C 2 7
G73 V_C D 2 7
G73 V_C E 2 7
G73 V_C F 2 7
G73 V_C G 2 7
G73 V_C H 2 7
G73 V_C I 2 7

i need to use another file, with values in red

Code:
 VAL
A 0.5
B 1.5
C 2.5
D 0.005
E 2
F 0.34
G 0.332
H 0.43
I 0.12


Need to multiply these reds in file 2 with the values in file 1(given columns would always be 2 in second file and 'n' in file 1)

to give the following result

Code:
  2013  2013  
    Make200  Make201  
    Merc  BMW  
    Jpur  Del  
    PT  PT  
   Aug Aug  
G73 V_C A 1 3.5
G73 V_C B 3 10.5
G73 V_C C 5 17.5
G73 V_C D 0.01 0.035
G73 V_C E 4 14
G73 V_C F 0.68 2.38
G73 V_C G 0.664 2.324
G73 V_C H 0.86 3.01
G73 V_C I 0.24 0.84

Thanks again for your expert help ! Smilie
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

comparing numbers in a file

Hello, I'm searching for a quick method to read numeric values from a file or a defined variable and identifying the largest number. For instance if the following numbers are in a file or defined to a variable: 09192007 09202007 09182007 09172007 09162007 What "short" method could be used to... (7 Replies)
Discussion started by: dusk2dawn
7 Replies

2. UNIX for Dummies Questions & Answers

Taking date difference

Hi, There is requirement in our project where in we have to calculate the elpased time of the process which are running and then if the elapsed time is greater than specific time we have to send a mail. In order to calculate the elapsed time we ahve use "ps -ef" command.The time displayed in... (6 Replies)
Discussion started by: Amey Joshi
6 Replies

3. UNIX for Dummies Questions & Answers

calculate the difference between numbers in lines of file

Hi everyone, i have files containing lines of number: 109 107 67 62 .. .. i want to calculate the difference between numbers in lines 1 and 2, 3 and 4, 5 and 6 and so on. would someone help me please?. Thanks (12 Replies)
Discussion started by: ahidayat
12 Replies

4. Shell Programming and Scripting

Comparing Columns and printing the difference from a particular file

Gurus, I have one file which is having multiple columns and also this file is not always contain the exact columns; sometimes it contains 5 columns or 12 columns. Now, I need to find the difference from that particular file. Here is the sample file: param1 | 10 | 20 | 30 | param2 | 10 |... (6 Replies)
Discussion started by: buzzusa
6 Replies

5. UNIX for Dummies Questions & Answers

Taking a average of a column of numbers

Hey all, I am relatively poor at programming and unfortunately don't have time to read about programming at this current moment. I wanted to be able to run a simple command to read a column of numbers in a file and give me the average of those numbers. In addition if I could specify the... (2 Replies)
Discussion started by: Leonidsg
2 Replies

6. Shell Programming and Scripting

Comparing text in 2 files and output difference in another file.

I have 2 files of almost same text apart from 2,3 ending lines. Now I want to get that difference in another file. e.g file1.txt is Filesystem Size Used Avail Use% Mounted on /dev/mapper/vg_livecd-lv_root 18G 2.4G 15G 14% / tmpfs 504M ... (12 Replies)
Discussion started by: kashif.live
12 Replies

7. Shell Programming and Scripting

Comparing 2 difference csv files

Hello, I have about 10 csv files which range from csv1 - csv10. Each csv file has same type/set of tabs and we have around 5-6 tabs for each of the csv file which have slightly different content(data). A sample of CSV1 is shown below: Joins: Data related to Joins, it can be any number of... (2 Replies)
Discussion started by: bobby1015
2 Replies

8. Shell Programming and Scripting

Comparing 2 CSV files and sending the difference to a new csv file

(say) I have 2 csv files - file1.csv & file2.csv as mentioned below: file1.csv ID,version,cost 1000,1,30 2000,2,40 3000,3,50 4000,4,60 file2.csv ID,version,cost 1000,1,30 2000,2,45 3000,4,55 6000,5,70 ... (1 Reply)
Discussion started by: Naresh101
1 Replies

9. Shell Programming and Scripting

Perl for comparing numbers from previous lines in a file?

Hi everyone I have a question for you, as I am trying to learn more about Perl and work with some weather data. I have an ascii file (shown below) that has 10 lines with different columns. What I would like is have Perl find an "anomalous" value by comparing a field with the values from the last... (2 Replies)
Discussion started by: lucshi09
2 Replies

10. UNIX for Beginners Questions & Answers

Comparing two files and list the difference with common first line content of both files

I have two file as given below which shows the ACL permissions of each file. I need to compare the source file with target file and list down the difference as specified below in required output. Can someone help me on this ? Source File ************* # file: /local/test_1 # owner: own #... (4 Replies)
Discussion started by: sarathy_a35
4 Replies
UDM_CAT_LIST(3) 							 1							   UDM_CAT_LIST(3)

udm_cat_list - Get all the categories on the same level with the current one

SYNOPSIS
array udm_cat_list (resource $agent, string $category) DESCRIPTION
Gets all the categories on the same level with the current one. The function can be useful for developing categories tree browser. PARAMETERS
o $agent - A link to Agent, received after call to udm_alloc_agent(3). o $category - RETURN VALUES
Returns an array listing all categories of the same level as the current $category in the categories tree. The returned array consists of pairs. Elements with even index numbers contain the category paths, odd elements contain the corresponding category names. $array[0] will contain '020300' $array[1] will contain 'Audi' $array[2] will contain '020301' $array[3] will contain 'BMW' $array[4] will contain '020302' $array[5] will contain 'Opel' ... etc. EXAMPLES
Following is an example of displaying links of the current level in format: Audi BMW Opel ... Example #1 udm_cat_list(3)example <?php $cat_list_arr = udm_cat_list($udm_agent, $cat); $cat_list = ''; for ($i=0; $i<count($cat_list_arr); $i+=2) { $path = $cat_list_arr[$i]; $name = $cat_list_arr[$i+1]; $cat_list .= "<a href="$_SERVER[PHP_SELF]?cat=$path">$name</a><br />"; } ?> SEE ALSO
udm_cat_path(3). PHP Documentation Group UDM_CAT_LIST(3)
All times are GMT -4. The time now is 11:46 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy