Sponsored Content
Top Forums Shell Programming and Scripting Compare fields in two files line by line Post 302856019 by dhruvmohan on Sunday 22nd of September 2013 12:06:12 PM
Old 09-22-2013
Compare fields in two files line by line

I am new to awk scripting.

I want to do a field by word (field) comparison of two files File1.txt and File2.txt.

The files contain a list of | (pipe) separated field.

**File 1:
-------------------
Code:
aaa|bbb|ccc|eee|fff
lll|mmm|nnn|ooo|ppp
rrr|sss|ttt|uuu|vvv**

File 2:
-------------------
Code:
aaa|bbb|ccc|eee|fff
rrr|sss|ttt|uuu|vvv
rrr|sss|ttt|uuu|uuu

We compare the same line no. in both the files.
Fields in Line 1 of both file match.

In Line 2 all the fields (lll, mmm, nnn, ooo, ppp) donot not match with all fields (rrr, sss, ttt, uuu, vvv) in line 2 of File 2. Similarly the 5th field of 3rd line in both the files donot match.

Hence Line no. 2 and Line no. 3 should get echoed by bash.

Both files will follow an order.

Last edited by Don Cragun; 09-22-2013 at 01:38 PM.. Reason: Add CODE tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Compare multiple fields in file1 to file2 and print line and next line

Hello, I have two files that I need to compare and print out the line from file2 that has the first 6 fields matching the first 6 fields in file1. Complicating this are the following restrictions 1. file1 is only a few thousand lines at most and file2 is greater than 2 million 2. I need to... (7 Replies)
Discussion started by: gillesc_mac
7 Replies

2. Shell Programming and Scripting

Compare two text files line by line

Hi all I need help on comparing two texts files line by line and print the total number of lines matched. Any help is appreciated. Thanks in advance. (4 Replies)
Discussion started by: my_Perl
4 Replies

3. Shell Programming and Scripting

Compare two files line by line

Query: There are two files as below - /home/rgupta/input/file.txt.arch (source file) /home/rgupta/output/file.txt (destination file) Files details are attached for the reference. Scenario: File /home/rgupta/input/file.txt.arch picked up by an application xyz. Application xyz does... (2 Replies)
Discussion started by: ravigupta2u
2 Replies

4. Shell Programming and Scripting

How to compare two files line by line

Using diff to compare 2 files FILE1: AAA AAA AAA AAA AAA AAA FILE2: BBB BBB AAA AAA BBB BBB diff FILE1 FILE2 (3 Replies)
Discussion started by: yannsun
3 Replies

5. Shell Programming and Scripting

how to read the contents of two files line by line and compare the line by line?

Hi All, I'm trying to figure out which are the trusted-ips and which are not using a script file.. I have a file named 'ip-list.txt' which contains some ip addresses and another file named 'trusted-ip-list.txt' which also contains some ip addresses. I want to read a line from... (4 Replies)
Discussion started by: mjavalkar
4 Replies

6. Shell Programming and Scripting

Perl how to compare two pdf files line by line

Hi Experts, Would really appreciate if anyone can guide me how to compare two pdf files line by line and report the difference to another file. (3 Replies)
Discussion started by: prasanth_babu
3 Replies

7. Shell Programming and Scripting

Comparison of fields then increment a counter reading line by line in a file

Hi, i have a scenario were i should compare a few fields from each line then increment a variable based on that. Example file 989878|8999|Y|0|Y|N|V 989878|8999|Y|0|N|N|V 989878|8999|Y|2344|Y|N|V i have 3 conditions to check and increment a variable on every line condition 1 if ( $3... (4 Replies)
Discussion started by: selvankj
4 Replies

8. Shell Programming and Scripting

How to read file line by line and compare subset of 1st line with 2nd?

Hi all, I have a log file say Test.log that gets updated continuously and it has data in pipe separated format. A sample log file would look like: <date1>|<data1>|<url1>|<result1> <date2>|<data2>|<url2>|<result2> <date3>|<data3>|<url3>|<result3> <date4>|<data4>|<url4>|<result4> What I... (3 Replies)
Discussion started by: pat_pramod
3 Replies

9. Shell Programming and Scripting

Search every line and compare fields

Hi All, I have situation where my file looks like this log.file. ID Start time IP SQL 1256152 05-Aug-15, 11:25:06 MST 10.54.20.33 Select * from TES 1004768 05-Aug-15, 11:25:06 MST 10.54.20.33 Select dummy 323323 05-Aug-15, 12:00:06 MST 10.15.20.77 ... (1 Reply)
Discussion started by: netdbaind
1 Replies

10. UNIX for Beginners Questions & Answers

Compare two files line by line in bash

Hello All! Thanks for taking time out and helping. My issue is, I have two files that have file names in it. Now, i need to go through each line of both the files and when the file names are different, i need to rename the file. Below is the example: File1</ fil1ename1.txt filename2,txt... (2 Replies)
Discussion started by: svks1985
2 Replies
ppp.Auth(4)						     Kernel Interfaces Manual						       ppp.Auth(4)

NAME
ppp.Auth - PPP authentication file format DESCRIPTION
The file contains values used by HP PPP's implementation of the link-level authentication protocols, (and (This implementation of both CHAP and PAP conforms to RFC 1334, CHAP is a stronger authentication mechanism and should be used whenever possible, in preference over PAP. Format Each authentication specification is on its own single line of up to 1023 characters. Comments begin with a and extend to the end of the line; blank lines, or lines beginning with a are ignored. Fields are separated by horizontal white space (blanks or tabs). If is using CHAP authentication, the first word on the line must match the peer's Name as received in a CHAP Challenge or Response packet and the second word is used for the Secret. If is using PAP authentication, the first word on the line must match the in a transmitted or received PAP Authenticate-Request packet and the second word is used for the Password. The default value used for the Name in transmitted CHAP packets or for the Peer-ID in transmitted PAP packets is the hostname(1) of the machine is running on. In the midst of the Name/Peer-ID and Secret/Password strings, ^x is translated into the appropriate control character before matching, and represents the character corresponding to the octal number xxx. Other special sequences are: Matches a space character (ASCII 0x20). Matches a horizontal tab character (ASCII 0x09). Matches a line feed character (ASCII 0x0a). Matches a carriage return character (ASCII 0x0d). The fields have the following meaning: name The Name field of a sent or received CHAP Challenge or Response message, or the Peer-ID field of a sent or received PAP Authenticate-Request message. For transmitted packets, this is the hostname unless overridden by the option. secret The secret word that the peer also knows. optional address restrictions A set of zero or more patterns restricting the addresses that we will allow to be used with the named peer. Patterns are separated by spaces or tabs and are parsed from left to right. Each pattern may begin with an exclamation mark to indi- cate that the following pattern should not be allowed. The rest of the pattern consists of digits and periods, and optionally a leading or trailing asterisk, which will match anything. If none of the patterns match, then the address will be allowed if the last pattern began with an exclamation point, and will be disallowed otherwise. This optional address restriction feature is available only for IPv4 addresses. EXAMPLES
The following provides with a secret for use when a peer claims to be other-host, robin, or "Jack's machine". SECURITY CONCERNS
The file should be mode 600 or 400, and owned by root. AUTHOR
was developed by the Progressive Systems. SEE ALSO
pppd(1), ppp.Devices(4), ppp.Dialers(4), ppp.Filter(4), ppp.Keys(4), ppp.Systems(4), services(4). RFC 792, RFC 1332, RFC 1334, RFC 1548. ppp.Auth(4)
All times are GMT -4. The time now is 02:12 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy