Sponsored Content
Full Discussion: To find and compare the data
Top Forums Shell Programming and Scripting To find and compare the data Post 302825015 by Shenbaga.d on Sunday 23rd of June 2013 02:21:08 AM
Old 06-23-2013
Hi,

here i have given the input files and output files, and awk command
awk 'FNR==NR {a[$1]=$4;next} $1 in a {if ($4==a[$1]) t=0; else {t=$4-a[$1]};print $0,t}' file1.tsv file2.tsv

i have to find the COL1 number in file2 and get the difference of the matched number's COL3 Value that is i have to find the 14150524 in file2 and take a difference of 39.88 - 37.88 and the result i want is like 10527 14150524 Sa 39.88 -2




File 1
Code:
SR.no	COL1	COL2	COL3
10527	14150524	Sa	39.88
10528	12311440	Sa	0
10529	12441731	Sa	111.66
10530	15120599	Sa	69.97
10531	21635123	Sa	149.99
10532	9854892	Sa	27.53
10533	14526541	Sa	67.06
10534	10993779	Sa	99
10535	15684120	Sa	112.99
10536	6051457	Sa	249
10537	10983989	Sa	149.97
10538	8222030	Sa	59
10539	10910428	Sa	237.2
10540	8477371	Sa	126.44

File2
Code:
SR.no	COL1	COL2	COL3
10536	6051457	Sb	249
10537	10983989	Sb	149.97
10538	8222030	Sb	59
10530	15120599	Sb	69.97
10531	21635123	Sb	149.99
10532	8477371	Sb	126.44
10533	14526541	Sb	67.09
10534	10993779	Sb	99
10535	15684120	Sb	112.99
10527	14150524	Sb	37.88
10528	12311440	Sb	0
10529	12441731	Sb	111.66
10539	10910428	Sb	237.2
10540	9854892	Sb	27.54

Result
Code:
SR.no	COL1	COL2	COL3	COL4
10527	14150524	Sa	39.88	0
10528	12311440	Sa	0	0
10529	12441731	Sa	111.66	0
10530	15120599	Sa	69.97	0
10531	21635123	Sa	149.99	0
10532	9854892	Sa	27.53	-98.91
10533	14526541	Sa	67.06	-0.03
10534	10993779	Sa	99	0
10535	15684120	Sa	112.99	0
10536	6051457	Sa	249	0
10537	10983989	Sa	149.97	0
10538	8222030	Sa	59	0
10539	10910428	Sa	237.2	0
10540	8477371	Sa	126.44	98.9

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

compare data

Hi, my problem is, I have to files, one is a log file of an actual execution, the other file is a pattern file. The entries "abcd,,!!11.22!!,3asdf" and "abcd,,!!xx.xx!!,3asdf" should be identified as equal. At the position of the x in the pattern file, the log file must have... (3 Replies)
Discussion started by: bensky
3 Replies

2. Shell Programming and Scripting

Compare data files

I would like to compare a data file (before and after a process has run) to identify if there are any differences. Can anyone help !! (1 Reply)
Discussion started by: ithomp
1 Replies

3. UNIX for Dummies Questions & Answers

Compare Data in the same file

Dear Unix-Gurus, I'm trying to write a script to compare the data in a log file. Here's how my logfile will look like: 'List All A0 Data in Destination Server' A0567 A0678 A0789 List A0 Files in Source Server A0567 A0678 A0789 So if the file match in Source Server match Destination... (1 Reply)
Discussion started by: lweegp
1 Replies

4. Shell Programming and Scripting

[urgent need help]compare data

hi all, very need help urgently :( i have a problem compare 2 files from solaris, the 2 files its shown below: data1.log : 6512345678 6512345677 20070131 073824 420 6511111111 6522222222 20070131 103747 87 6522222222 6233333333 ... (2 Replies)
Discussion started by: bucci
2 Replies

5. Shell Programming and Scripting

Get data from 3 differrnt oracle DB & then compare data

Hi All, I have a requirement to write a shell script for the following... we have 3 different database.... lets say A, B, C From these 3 DBs, i need to get data.. all have 3 different table...a,b, c A.a => Emp_code, count(*) B.b => emp_code, count(*) C.c => emp_code, copunt(*) Once get this... (4 Replies)
Discussion started by: Amit.Sagpariya
4 Replies

6. Shell Programming and Scripting

Compare 2 files and match column data and align data from 3 column

Hello experts, Please help me in achieving this in an easier way possible. I have 2 csv files with following data: File1 08/23/2012 12:35:47,JOB_5330 08/23/2012 12:35:47,JOB_5330 08/23/2012 12:36:09,JOB_5340 08/23/2012 12:36:14,JOB_5340 08/23/2012 12:36:22,JOB_5350 08/23/2012... (5 Replies)
Discussion started by: asnandhakumar
5 Replies

7. Shell Programming and Scripting

Compare data in two files

Gents, Can you help please I have a data base with lot information (file2) and I have some data in (file1) to compare. Then the comparison should be done using the following keys: Example ( values from file1 ) key1 = columns from 20-34 substr($0,20,15) 66705.00 19793 key2 = columns... (5 Replies)
Discussion started by: jiam912
5 Replies

8. UNIX for Dummies Questions & Answers

Compare data - Match first column and compare second

Hi guys, looking for some help with a way to compare data in two files but with some conditions. example, File 1 consists of site1,10.1.1.1 site2,20.2.2.2 site3,30.3.3.3 File 2 contains site1,l0.1.1.1 site2,50.1.1.1 site3,30.3.3.3 site4,40.1.1.1 I want to be able to match the... (1 Reply)
Discussion started by: mutley2202
1 Replies

9. Shell Programming and Scripting

Compare data with reference from other file

Gents, Please can you help with this. I have a big file (file2) which contends many records increment every 25 rows ( column 1 ). Then I have other file as reference (file1).. column 1 to 11. I want to compare that all values in file2 (column 2 to 12.) match with values in... (2 Replies)
Discussion started by: jiam912
2 Replies

10. Shell Programming and Scripting

Compare data with while if else loop ?!

Good midday and hello to everyone! =) If I describe some things wrong please be aware, that english is not my native language!! :D I'm a bit stuck with a script I need to finish. Due to data protection I need to hide some paths but that should be no problem. My script connects to a db2... (1 Reply)
Discussion started by: dsondermann
1 Replies
pbind(1M)						  System Administration Commands						 pbind(1M)

NAME
pbind - control and query bindings of processes or LWPs SYNOPSIS
pbind -b processor_id pid [/lwpid]... pbind [-q] [pid [/lwpid]...] pbind -Q [processor_id...] pbind -u pid [/lwpid]... pbind -U [processor_id...] DESCRIPTION
pbind controls and queries bindings of processes and LWPs (lightweight processes) to processors. pbind can also remove processor bindings that were previously established. When an LWP is bound to a processor, it will be executed only by that processor except when the LWP requires a resource that is provided only by another processor. The binding is not exclusive, that is, the processor is free execute other LWPs as well. Bindings are inherited, so new LWPs and processes created by a bound LWP will have the same binding. Binding an interactive shell to a pro- cessor, for example, binds all commands executed by the shell. Superusers may bind or unbind any process or LWP, while other users can bind or unbind any process or LWP for which they have permission to signal, that is, any process that has the same effective user ID as the user. OPTIONS
The following options are supported: -b processor_id Binds all or a subset of the LWPs of the specified processes to the processor processor_id. Specify processor_id as the processor ID of the processor to be controlled or queried. processor_id must be present and on-line. Use the psrinfo command to determine whether or not processor_id is present and on-line. See psrinfo(1M). -q Displays the bindings of the specified processes or of all processes. If a process is composed of multiple LWPs which have different bindings and the LWPs are not explicitly specified, the bindings of only one of the bound LWPs will be displayed. The bindings of a subset of LWPs can be displayed by appending "/lwpids" to the process IDs. Multiple LWPs may be selected using "-" and "," delimiters. See EXAMPLES. -Q Displays the LWPs bound to the specified list of processors, or all LWPs with processor bindings. For processes composed of multiple LWPs, the bindings of individual LWPs will be displayed. -u Removes the bindings of all or a subset of the LWPs of the specified processes, allowing them to be executed on any on-line processor. -U Removes the bindings of all LWPs bound to the specified list of processors, or to any processor if no argument is specified. OPERANDS
The following operands are supported: pid The process ID of the process to be controlled or queried. lwpid The set of LWP IDs of the specified process to be controlled or queried. The syntax for selecting LWP IDs is as follows: 2,3,4-8 LWP IDs 2, 3, and 4 through 8 -4 LWPs whose IDs are 4 or below 4- LWPs whose IDs are 4 or above processor_id The processor ID of the processor to be controlled or queried. EXAMPLES
Example 1: Binding Processes The following example binds processes 204 and 223 to processor 2: example% pbind -b 2 204 223 process id 204: was 2, now 2 process id 223: was 3, now 2 Example 2: Unbinding a Process The following example unbinds process 204: example% pbind -u 204 Example 3: Querying Bindings The following example queries bindings. It demonstrates that process 1 is bound to processor 0, process 149 has at least one LWP bound to CPU3, and process 101 has no bound LWPs. example% pbind -q 1 149 101 process id 1: 0 process id 149: 3 process id 101: not bound Example 4: Querying LWP Bindings The following example queries bindings of LWPs. It demonstrates that LWP 1 of process 149 is bound to CPU3, and LWP 2 of process 149 is not bound. example% pbind -q 149/1-2 lwp id 149/1: 3 lwp id 149/2: not bound Example 5: Querying LWP Bindings for Processor 2: The following example queries all LWPs bound to processor 2: example% pbind -Q 2 lwp id 149/4: 2 lwp id 149/5: 2 ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ EXIT STATUS
The following exit values are returned: 0 Successful completion. >0 An error occurred. SEE ALSO
psradm(1M), psrinfo(1M), psrset(1M), processor_bind(2), processor_info(2), sysconf(3C), attributes(5) DIAGNOSTICS
pbind: cannot query pid 31: No suchprocess The process specified did not exist or has exited. pbind: cannot bind pid 31: Not owner The user does not have permission to bind the process. pbind: cannot bind pid 31: Invalid argument The specified processor is not on-line. SunOS 5.10 18 July 2004 pbind(1M)
All times are GMT -4. The time now is 01:43 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy