Thanks For the reply Frank, it is still not working It is writing the second file as it is in the out put file. It is not appending the data in the record.
Can l you please let me know why are you adding 1 at after the append function?
Code:
awk -F; 'NR==FNR{a[$5]=$4; next} {s=substr($0,13,8)} s in a {$0=$0 a[s]}1' file1 file2
Thanks,
Ajay
Last edited by Scrutinizer; 04-23-2014 at 02:21 PM..
Reason: code tags
Hi there,
I have written a script called "compare" (see below) to make comparison between 2 files namely test_put.log and Output_A0.log
#!/bin/ksh
while read file
do
found="no"
while read line
do
echo $line | grep $file > /dev/null
if
then
echo $file found
found="yes"
break
fi... (3 Replies)
Hi all,
Am new to scripting. So i just need your ideas to help me out. Here goes my requirement.
I have two csv files
1.csv 2.csv
abc,1.24 abc,1
def,2.13 def,1
I need to compare the first column of 1.csv with 2.csv and if matches then need to compare... (2 Replies)
I've got two large csv text table files with different number of columns each.
I have to compare them based on first two columns and create resulting file
that would in case of matched first two columns include all values from first one and all values (except first two colums) from second one. I... (5 Replies)
Hi!
I have one file with data that looks like this:
1 data data data data
2 data data data data
3 data data data data
.
.
.
1 data data data data
2 data data data data
3 data data data data
.
.
.
I would like to have awk to write each block to a separate file, like this:
1... (3 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)
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)
Hi all,
I have 2 files:Column1 of first file has to be matched with column 3 of second file
first file contain DATA like this in 2 columns one with gene name second with whether CAD,HT,RA T2Dor any one
column 1 column2
ARFGEF2 CAD
DDEF2 CAD
PSCD3 CAD
PSCD4 CAD
CAMK1... (5 Replies)
Hi,
I need to compare 2 text files with around 60000 rows and 1 column. I need to compare these and write the mismatch data to 3rd file.
File1 - file2 = file3
wc -l file1.txt
58112
wc -l file2.txt
55260
head -5 file1.txt
101214200123
101214700300
101250030067
101214100500... (10 Replies)
Kwargs(3pm) User Contributed Perl Documentation Kwargs(3pm)NAME
Kwargs - Simple, clean handing of named/keyword arguments.
VERSION
version 0.01
SYNOPSIS
use Kwargs;
# just named
my ($foo, $bar, baz) = kw @_, qw(foo bar baz);
# positional followed by named
my ($pos, $opt_one, $opt_two) = kwn @_, 1, qw(opt_one opt_two)
# just a hashref
my $opts = kw @_;
# positional then hashref
my ($one, $two, $opts) = kwn @_, 2;
WHY ?
Named arguments are good, especially when you take lots of (sometimes optional) arguments. There are two styles of passing named arguments
(by convention) in perl though, with and without braces:
sub foo {
my $args = shift;
my $bar = $args->{bar};
}
foo({ bar => 'baz' });
sub bar {
my %args = @_;
my $foo = $args{foo};
}
bar(foo => 'baz');
If you want to support both calling styles (because it should be mainly a style issue), then you have to do something like this:
sub foo {
my $args = ref $_[0] eq 'HASH' ? $_[0] : { @_ };
my $bar = $args->{bar};
}
Which is annoying, and not even entirely correct. What if someone wanted to pass in a tied object for their optional arguments? That could
work, but what are the right semantics for checking for it? It also gets uglier if you want to unpack your keyword arguments in one line
for clarity:
sub foo {
my ($one, $two, $three) =
@{ ref $_[0] eq 'HASH' ? $_[0] : { @_ } }{qw(one two three) };
}
Did I say clarity? HAHAHAHAHA! Surely no one would actually put something like that in his code. Except I found myself typing this very
thing, and That Is Why.
EXPORTS
Two functions (kw and kwn) are exported by default. You can also ask for them individually or rename them to something else. See
Sub::Exporter for details.
kw(@array, @names)
Short for "kwn(@array, 0, @names)"
kwn(@array, $number_of_positional_args, @names)
Conceptually shifts off n positional arguments from array, then figures out whether the rest of the array is a list of key-value pairs or a
single argument (usually, but not necessarily, a hashref). If you passed in any @names, these are used as keys into the hash, and the
values at those keys are appended to any positional arguments and returned. If you do not pass @names, you will get a hashref (or whatever
the single argument was, like a tied object) back.
Note that if the single argument cannot be dereferenced as a hashref, this can die. No attempt is made by this module to handle the
exception.
AUTHOR
Paul Driver <frodwith@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2011 by Paul Driver <frodwith@cpan.org>.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
perl v5.12.4 2011-01-24 Kwargs(3pm)