I am not an expert in awk, SED, etc... but I really hope there is a way to do this, because I don't want to have to right a program. I am using C shell.
As you can see I have 2 files. FILE 1 is the good file and FILE 2 is the bad file. Each File starts with a Header(H) record and ends with a trailer (T) record. Those records can just be written in and out, or ignored. Each M and C record go together. Each M record can have multiple C records, or no C records.
Basically what I am looking to do is to compare the C records from FILE 1 and FILE 2.
If the C record is on both files then I don't want to write it out to any file. If the C record is only on FILE 1 then I want to write it out to a GOOD FILE. If the record is only on FILE 2, then I want to write it out to a BAD FILE. I would like to try to keep the combination of M/C records together if possible. In the C records we are only comparing the Id codes (Column 4)(BBBBBB, KKKKKK, etc...)
The solution for the above example should be:
I would have to say that the file is not really in sorted order and not sure how to sort it.
Any help would be appreciated.
Thanks.
Moderator's Comments:
Use code tags!
Last edited by zaxxon; 06-30-2010 at 01:35 AM..
Reason: code tags
Hi,
I am using Sun Solaris - SunOS. I have two fixed width files shown below. I am trying to find the changes in the records in the Newfile.txt for the records where the key column matches. The first column is a key column (example: A123).
If there are any new or deletion of records in the... (4 Replies)
Assume we have two files - FileA and FileB. Content of files are as shown below :
FileA:1001,value1,value4,value8,value9
1002,value4,value32,value46,value33
1503,value5,value45,value68,value53
1605,value4,value67,value56,value57
1073,value5,value45,value68,value53... (3 Replies)
hi.. I want to compare records present in 1 file with those in 3 other files and print those records of file 1 which are not present in any of the files. for eg -
file1 file2 file3 file4
1 1 5 7
2 2 6 9
3
4
5
6
7
8
9
... (3 Replies)
Good morning all,
I have a problem that is one step beyond a standard awk compare.
I would like to compare three files which have several thousand records against a fourth file. All of them have a value in each row that is identical, and one value in each of those rows which may be duplicated... (1 Reply)
I have this code
awk 'NR==FNR{a=$1;next} a' file1 file2
which does what I need it to do, but for only two files. I want to make it so that I can have multiple files (for example 30) and the code will return only the items that are in every single one of those files and ignore the ones... (7 Replies)
Hi ,
My requirement is to Compare 2 files having different number of columns and records and get the ouptut containing all the non-matching records from File A(with all column values ) .Example data below :
File A contains following :
Aishvarya |1234... (4 Replies)
I have 2 zip files which have about 20 million records in each file. file 2 will have additional records than file 1. I want to compare the records in both the files and capture the new records from file 2 into another file file3. Please help me with a command/script which provides me the desired... (8 Replies)
I'm trying to compare the first column values in two different files that use a numerical value as the key and output the more meaningful value found in the second column of file1 in front of the matching line(s) in file2. My problem is that file2 has multiple records. For example given:
FILE1... (4 Replies)
I have a task where I need to code a shell script to extract a 10 min range (10 min from now until now) extract of a log file.
I taught I could simply use a command that would say something like Start=date - 10 min but I didn't find anything. Looks like the only solution would have to code a... (3 Replies)