Complex Compare

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Complex Compare
# 1  
Old 07-25-2011
Complex Compare

Hi All,

Above are the two input file's:
Always I use to get three rows for File1.txt
File1.txt (fixed width) 2nd line i will get date and 3rd record i will get a number.
File2.txt (Pile delimeter) will contains 'n' number of records were header & footer is fixed.

I need to verify both the below feilds values are same or not?
File1.txt 2nd record date -> File2.txt only header record 3rd column will contains the date
File1.txt 3rd record number -> File2.txt last record number

Thanks in Advance

Last edited by kmsekhar; 07-25-2011 at 05:15 PM..
# 2  
Old 07-25-2011
awk -F\| 'NR==2{d=$0;next}NR==3{n=$0;next}NR>1&&FNR==1&&$3==d{p=1}END{sub(".","");if (p&&$0==n) {print "same fields"}else{print "different fields"}}' file1.txt file2.txt

This User Gave Thanks to bartus11 For This Post:
# 3  
Old 07-25-2011
Any help on this how to proceed...
# 4  
Old 07-25-2011
What do you mean? Is my code not working for you?
# 5  
Old 07-26-2011
Its working fine thanks a lot...
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. 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, site2, site3, File 2 contains site1,l0.1.1.1 site2, site3, site4, I want to be able to match the... (1 Reply)
Discussion started by: mutley2202
1 Replies

2. Shell Programming and Scripting

Complex if then else

for i in $(condition ONE);do for e in $(CONDITION TWO);do if ; then command 1 command 2 command 3 else if ; then command 1 command 2 command 3 else if ; then ... (6 Replies)
Discussion started by: elilmal
6 Replies

3. Shell Programming and Scripting

Complex query

A file whose location i am not aware of contains the below text <url>jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(FAILOVER=on)(ADDRESS=(PROTOCOL=TCP) ( (1 Reply)
Discussion started by: mohtashims
1 Replies

4. Shell Programming and Scripting

Complex Script

hey... i had a big problem with my professor i have 3 simple archives in.txt -> had all timestamps of users logon (100lines) ex. 111111 222222 333333 out.txt -> had all timestamps of users logof (100lines) ex. 111113 222225 333332 commands.txt... (9 Replies)
Discussion started by: beandj
9 Replies

5. 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

6. UNIX for Dummies Questions & Answers

Complex Commands

I need to ideas for some complex commands for a script file. Any ideas would be greatly appricated (2 Replies)
Discussion started by: trob
2 Replies

7. Shell Programming and Scripting

Complex use with awk

Hi , I have file named docs.txt The content of the file look like this: DOC disk location Size ======= ===== ============= ========= TXT A /dev/dm-1 10 TXT B /dev/dm-2 10 BIN C ... (3 Replies)
Discussion started by: yoavbe
3 Replies

8. Shell Programming and Scripting

Compare two arrays in sh or compare two fields

I want a soultion to compare two arrays in sh with an easy way.I want a solution to synchrose users between different AIX servers where no NIS is available. All users are meant to be same on all 10 servers. So the approach is to consider first server as master user repository and whatever the users... (0 Replies)
Discussion started by: rijeshpp
0 Replies
Login or Register to Ask a Question