Compare two files using awk command recursively


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Compare two files using awk command recursively
Prev   Next
# 1  
Old 04-28-2014
Compare two files using awk command recursively

I want to compare two files, 1) Compare Each query result. 2) Compare Only first row of the Query output 3) Compare Time (3rd column), First file time is lesser than 2nd file then print the PO_NUM else do nothing.

File1:
Code:
C:\script>call transaction 1OPOP

C:\script>Select ID, PO_ID, TIME, DES From Table
ID          PO_NUM          TIME                        DES         
-------     ------------    ---------------             -----
11232323    1OPOP           2012-08-01-23.02.50.040000  SAMPLE  
11232324    1OPOP           2013-09-01-23.02.50.040000  SAMPLE  
11232325    1OPOP           2014-09-01-23.02.50.040000  SAMPLE  
11232326    1OPOP           2015-09-01-23.02.50.040000  SAMPLE
4 record(s) selected.

C:\script>call transaction 1XDXD

C:\script>Select ID, PO_ID, TIME, DES From Table
ID          PO_NUM          TIME                        DES         
-------     ------------    ---------------             -----
11232323    1XDXD           2012-07-01-23.02.50.040000  SAMPLE  
11232324    1XDXD           2013-09-01-23.02.50.040000  SAMPLE  
11232325    1XDXD           2014-08-01-23.02.50.040000  SAMPLE  
3 record(s) selected.

C:\script>call transaction 1IOIO

C:\script>Select ID, PO_ID, TIME, DES From Table
ID          PO_NUM          TIME                        DES         
-------     ------------    ---------------             -----
11232323    1IOIO           2011-06-01-23.02.50.040000  SAMPLE  
11232324    1IOIO           2012-09-01-23.02.50.040000  SAMPLE  
2 record(s) selected.

File2:

Code:
C:\script>call transaction 1OPOP

C:\script>Select ID, PO_ID, TIME, DES From Table
ID          PO_NUM          TIME                    DES         
-------     ------------    ---------------             -----
11232323    1OPOP           2012-09-01-23.02.50.040000  SAMPLE  
11232324    1OPOP           2013-09-01-23.02.50.040000  SAMPLE  
11232325    1OPOP           2014-09-01-23.02.50.040000  SAMPLE  
11232326    1OPOP           2015-09-01-23.02.50.040000  SAMPLE
4 record(s) selected.

C:\script>call transaction 1XDXD

C:\script>Select ID, PO_ID, TIME, DES From Table
ID          PO_NUM          TIME                    DES         
-------     ------------    ---------------             -----
11232323    1XDXD           2012-08-01-23.02.50.040000  SAMPLE  
11232324    1XDXD           2013-09-01-23.02.50.040000  SAMPLE  
11232325    1XDXD           2014-08-01-23.02.50.040000  SAMPLE  
3 record(s) selected.

C:\script>call transaction 1IOIO

C:\script>Select ID, PO_ID, TIME, DES From Table
ID          PO_NUM          TIME                DES         
-------     ------------    ---------------             -----
11232323    1IOIO           2011-05-01-23.02.50.040000  SAMPLE  
11232324    1IOIO           2012-09-01-23.02.50.040000  SAMPLE  
2 record(s) selected.

Thanks in Advance
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Simple awk command to compare two files and print first difference

Hello, I have two text files, each with a single column, file 1: 124152970 123899868 123476854 54258288 123117283 file 2: 124152970 123899868 54258288 123117283 122108330 (5 Replies)
Discussion started by: LMHmedchem
5 Replies

2. Shell Programming and Scripting

[awk] Compare two files

HI!! I am trying to compare two files using AWK but I have some problems. I need to count how many times letters are used in two texts. This is my script { long=length($0) for (i=1;i<=long;i++) { aux=substr($0,i,1) if ( aux != " " && aux != "" ) ... (7 Replies)
Discussion started by: ettore8888
7 Replies

3. UNIX for Dummies Questions & Answers

awk command to compare files by column

So I have this issue. I have 4 files. the first one is the master file who has all possible combinations: file 1 - a - b - c - d - e the other three have some of the letters and a number instead of - for example file 2 34 a 5 c file 3 10 b 12 ... (3 Replies)
Discussion started by: Quijotes
3 Replies

4. Shell Programming and Scripting

awk compare files

I have a below requirement and trying to compare the files using awk File 1 - Already stored on a prev day id | text | email id --------------------------------- 89564|this is line 1 | xyz@sample.txt 985384|this is line 2 | abc@sample.txt 657342|this is line 3 |... (3 Replies)
Discussion started by: rakesh_411
3 Replies

5. Shell Programming and Scripting

Script to compare files recursively using sdiff

Hi All, I have been surfing to get some idea on how to compare same files from two different paths. one path will have oldfiles directory and another path will have newfiles directory. Each main directories will have sub-directories in them and each sub-directories inturn will have... (3 Replies)
Discussion started by: Optimus81
3 Replies

6. Shell Programming and Scripting

awk command to compare a file with set of files in a directory using 'awk'

Hi, I have a situation to compare one file, say file1.txt with a set of files in directory.The directory contains more than 100 files. To be more precise, the requirement is to compare the first field of file1.txt with the first field in all the files in the directory.The files in the... (10 Replies)
Discussion started by: anandek
10 Replies

7. Shell Programming and Scripting

Compare two files with awk

Hello, I have a script which extracts the values from a csv file when a specific date is entered : #!/bin/sh awk 'BEGIN{printf("Entrez la date : "); getline date < "-"} $0 ~ date {f=1;print;next} /^{2}\//{f=0} f' file1.csv This script gives me a number of lines with different values. ... (6 Replies)
Discussion started by: freyr
6 Replies

8. Shell Programming and Scripting

Require compare command to compare 4 files

I have four files, I need to compare these files together. As such i know "sdiff and comm" commands but these commands compare 2 files together. If I use sdiff command then i have to compare each file with other which will increase the codes. Please suggest if you know some commands whcih can... (6 Replies)
Discussion started by: nehashine
6 Replies

9. Shell Programming and Scripting

using awk to compare two files

Hi, I have two tab separated files; file1: S.No ddi fi cu o/l t+ t- 1 0.5 0.6 o 0.1 0.2 2 0.2 0.3 l 0.3 0.4 3 0.5 0.8 l 0.1 0.6 file2: S.No ddi fi cu o/l t+ t- 1 0.8 0.9 o 0.5 0.6 2 0.5 0.2 o 0 0 3 0.2 0.3 l 0 0 4 0.5 0.6 l 0 0 (1 Reply)
Discussion started by: vasanth.vadalur
1 Replies

10. Shell Programming and Scripting

awk compare 2 files

Hi i hope some awk gurus here can help me.. here is what i need i have 2 files: File1 152445 516532 405088.pdf 152445 516533 405089.pdf 152491 516668 405153.jpg 152491 520977 408779.jpg 152491 0 409265.pdf File2 516532 /tmp/MainStreet_Sum09_Front_FNL.pdf 516533... (9 Replies)
Discussion started by: kenray
9 Replies
Login or Register to Ask a Question