Sponsored Content
Full Discussion: Compare and Merge files
Top Forums Shell Programming and Scripting Compare and Merge files Post 302752769 by nua7 on Monday 7th of January 2013 01:20:46 PM
Old 01-07-2013
Thanks LMHmedchem But I need to do this in awk or sed.

Also found another way of doing it , incase it is helpful for others.


Code:
awk -v input_file=file1 'BEGIN { FS="|"; while((getline<input_file)>0){sub1=substr($0,1,11); subArr[sub1]=""}}{ if ($1 in subArr) print $0;}' file2  > file3


.

Last edited by Scrutinizer; 01-07-2013 at 02:28 PM.. Reason: icode tags to code tags
This User Gave Thanks to nua7 For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Compare two files and merge columns in a third

Hi, I'm working with snmp, with a little script I'm able to obtain from a switch a list with a couple of values with this format Port Mac 1 00:0A:0B:0C:0D:0E .... (hundred of entries) Now with a simple arp on a router I am able to obtain another list 00:0A:0B:0C:0D:0E... (20 Replies)
Discussion started by: CM64
20 Replies

2. Shell Programming and Scripting

compare the column from 3 files and merge that line

I have 3 file, each of has got 80000 records. file1.txt ----------------------- ABC001;active;modify;accept; ABC002;notactive;modify;accept; ABC003;notactive;no-modify;accept; ABC004;active;modify;accept; ABC005;active;no-modify;accept; file2.txt ---------------------------... (8 Replies)
Discussion started by: ganesh_mak
8 Replies

3. Shell Programming and Scripting

Merge files of differrent size with one field common in both files using awk

hi, i am facing a problem in merging two files using awk, the problem is as stated below, file1: A|B|C|D|E|F|G|H|I|1 M|N|O|P|Q|R|S|T|U|2 AA|BB|CC|DD|EE|FF|GG|HH|II|1 .... .... .... file2 : 1|Mn|op|qr (2 Replies)
Discussion started by: shashi1982
2 Replies

4. UNIX for Dummies Questions & Answers

compare columns from 2 files and merge

Dear all, Being new to Unix i have a problem. I have 2 files: File 1: 118,1,0,2,3,0,5,0.3,0,0.3,0.6,1 118,2,1,2,2,0,5,0.4,0,0.4,0.4,1 118,4,2,0,3,0,5,0.7,0,0.3,0.6,1 118,6,4,1,0,0,5,0.8,0,0.2,0,1 File 2: 118,1,BFGL-NGS-109695,3610326,0,18,1,0.556,0.389,0.056,0.25,0.8183... (2 Replies)
Discussion started by: samwilkinson
2 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. Shell Programming and Scripting

Shell Scripting: Compare pattern in two files and merge the o/p in one.

one.txt ONS.1287677000.820.log 20Oct2010 ONS.1287677000.123.log 21Oct2010 ONS.1287677000.456.log 22Oct2010 two.txt ONS.1287677000.820.log:V AC CC EN ONS.1287677000.123.log:V AC CC EN ONS.1287677000.820.log:V AC CC EN In file two.txt i have to look for pattern which column one... (17 Replies)
Discussion started by: saluja.deepak
17 Replies

7. Shell Programming and Scripting

AWK compare/merge

File1 2917,`0722,RDF1+TDEV,90(6),33,03E:0_12E:0,10000000c96c4af3_10000000c96c6e88,BL_db00p01e 2917,`0781,RDF1+TDEV,100(5),33,03E:0_12E:0,10000000c96c4af3_10000000c96c6e88,BL_db00p01e File2 2917,`0722,RDF1+TDEV,90(6),03E:0_12E:0,10000000c96c4af3_10000000c96c6e88,BL_db00p01e... (4 Replies)
Discussion started by: greycells
4 Replies

8. Shell Programming and Scripting

Checking in a directory how many files are present and basing on that merge all the files

Hi, My requirement is,there is a directory location like: :camp/current/ In this location there can be different flat files that are generated in a single day with same header and the data will be different, differentiated by timestamp, so i need to verify how many files are generated... (10 Replies)
Discussion started by: srikanth_sagi
10 Replies

9. Shell Programming and Scripting

Compare two files and merge into third

Hello: Newbie with Awk. Trying to compare two files and merge data based on CID. Please see the input file format and desired output. Any help is appreciated. TIA Input File1 CID1 --- TYP1 --- DCN1 --- INDATE1 --- IN-DATA1 CID2 --- TYP2 --- DCN2 --- INDATE2 --- IN-DATA2 CID3 ---... (6 Replies)
Discussion started by: wincrazy
6 Replies

10. Shell Programming and Scripting

Compare and merge two big CSV files

Hi all, i need help. I have two csv files with a huge amount of data. I need the first column of the first file, to be compared with the data of the second, to have at the end a file with the data not present in the second file. Example File1: (only one column) profile_id 57036226... (11 Replies)
Discussion started by: SirMannu
11 Replies
SVK::Merge::Info(3)					User Contributed Perl Documentation				       SVK::Merge::Info(3)

NAME
SVK::Merge::Info - Container for merge ticket information SYNOPSIS
use SVK::Merge::Info; my $minfo = SVK::Merge::Info->new( $svk_merge_property ); DESCRIPTION
An "SVK::Merge::Info" object represents a collection of merge tickets, including repository UUID, path and revision. CONSTRUCTORS
new Takes a single argument with the value of an "svk:merge" property. METHODS
add_target Add a single SVK::Target::Universal or SVK::Path to the collection of merge tickets. del_target Remove a single SVK::Target::Universal or SVK::Path from the collection of merge tickets. remove_duplicated Takes a single SVK::Merge::Info object as an argument. Removes merge tickets which are present in the argument and for which the argument's revision is less than or equal to our revision. subset_of Takes a single SVK::Merge::Info object as an argument. Returns true if our set of merge tickets is a subset of the argument's merge tickets. Otherwise, returns false. is_equal Takes a single SVK::Merge::Info object as an argument. Returns true if our set of merge tickets is equal to argument's. Otherwise, returns false. union Return a new SVK::Merge::Info object representing the union of ourself and the SVK::Merge::Info object given as the argument. resolve verbatim as_string Serializes this collection of merge tickets in a form suitable for storing as an svk:merge property. TODO
Document the merge and ticket tracking mechanism. SEE ALSO
SVK::Editor::Merge, SVK::Command::Merge, Star-merge from GNU Arch perl v5.10.0 2008-08-04 SVK::Merge::Info(3)
All times are GMT -4. The time now is 11:29 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy