Sequential comparison (one row with file and so on)


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Sequential comparison (one row with file and so on)
# 1  
Old 06-01-2009
Sequential comparison (one row with file and so on)

Dear linux experts,

I'd like to ask for your support, I've read some posts in this forum about files comparison but haven't found what I'm looking for. I need to create a sequential script to compare row-by-row one file with 34 similar files but without success so far. This is what I get:

Image

I need to compare the first row of base file with each row of file 1. Then, compare the second row of the base file with each row of file 1, and so on in the same way. When both values are the same, I need these values to be displayed in the screen (my bash shell). For instance in the above example, it should appear in the screen "889935.66 9554656.32 -88.5" after the first scan, after the second scan it should appear "5584452.22 4455874.12 -714.2".

I will be really grateful if you can help me,

Best regards,

Gery
Sequential comparison (one row with file and so on)-examplepng
# 2  
Old 06-01-2009
Code:
awk 'FNR==NR{a[$0];next}($0 in a)' base.txt file.txt

# 3  
Old 06-02-2009
Thanks, it worked perfectly.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Search row by row from one file to another file if match is found print few colums of file 2

this is the requirement list.txt table1 table2 table3 testfile.txt name#place#data#select * from table1 name2#place2#data2#select * from table 10 innerjoin table3 name2#place2#data2#select * from table 10 output name place table1 name2 place table3 i tried using awk (7 Replies)
Discussion started by: vamsekumar
7 Replies

2. Shell Programming and Scripting

Sequential extraction of first row

I do have a large text file (tab delimited) of the following format RT_1 34 67 RT_1 9 10 RT_1 98 56 RT_2 09 89 RT_2 23 45 RT_2 90 76 RT_3 98 21 RT_4 23 90 RT_4 67 90 RT_4 79 23 RT_5 8 9 I want to parse every first row (complete row), whenever a new value in column 1 (here... (2 Replies)
Discussion started by: Lucky Ali
2 Replies

3. Shell Programming and Scripting

Subtracting each row from the first row in a single column file using awk

Hi Friends, I have a single column data like below. 1 2 3 4 5 I need the output like below. 0 1 2 3 4 where each row (including first row) subtracting from first row and the result should print below like the way shown in output file. Thanks Sid (11 Replies)
Discussion started by: ks_reddy
11 Replies

4. Programming

Tool to simulate non-sequential disk I/O (simulate db file sequential read) in C POSIX

Writing a Tool to simulate non-sequential disk I/O (simulate db file sequential read) in C POSIX I have over the years come across the same issue a couple of times, and it normally is that the read speed on SAN is absolutely atrocious when doing non-sequential I/O to the disks. Problem being of... (7 Replies)
Discussion started by: vrghost
7 Replies

5. Shell Programming and Scripting

row Comparison

(5 Replies)
Discussion started by: number10
5 Replies

6. Shell Programming and Scripting

Get a group of line from different file and put them into one file row by row

hi guys, today i'm stuck in a new problem. the title explain more or less but a particular had been omitted. So i'm going to describe below the situation with an example. I have different html files and each of them have a consecutive lines group inside that i want to extract. example: ... (8 Replies)
Discussion started by: sbobotex
8 Replies

7. Shell Programming and Scripting

How to do row comparison in shell script

Hi, I need help on doing the below thing in shell script. I have a file with millions of rows called "abc.txt". i have another file with millions of rows called "xyz.txt". I would like to do the below operation. Open the abc.txt, read the first line, do some operations on the column... (2 Replies)
Discussion started by: informsrini
2 Replies

8. Shell Programming and Scripting

consecutive row comparison in awk (?)

hi, I'm totally new to this forum and to awk. I have what I thought was a simple problem, but I can't get anything to work. Here is an example input file: 3.85 4018.4 3.9 4068.4 3.95 4082.9 4 4099.7 # Property:.......etc. 0 4733.3 0.05 4659.7 0.1 4585.6 0.15 4466.2 Two... (2 Replies)
Discussion started by: ogga
2 Replies

9. Programming

Reading special characters while converting sequential file to line sequential

We have to convert a sequential file to a 80 char line sequential file (HP UX platform).The sequential file contains special characters. which after conversion of the file to line sequential are getting coverted into "new line" or "tab" and file is getting distorted. Is there any way to read these... (2 Replies)
Discussion started by: Rajeshsu
2 Replies

10. Shell Programming and Scripting

Changing the column for a row in a text file and adding another row

Hi, I want to write a shell script which increments a particular column in a row from a text file and then adds another row below the current row with the incremented value . For Eg . if the input file has a row : abc xyz lmn 89 lm nk o p I would like the script to create something like... (9 Replies)
Discussion started by: aYankeeFan
9 Replies
Login or Register to Ask a Question