05-27-2009
instead of while/getline combo for reading the files, you could could use a separate combos of FILENAME/ARGV and read the files into arrays. Checking the content of 'filea' in multiple read-in arrays should be straight-forward.
Search the forums for the terms mentioned above and it should give you enough as a starting hint.
Good luck.
Last edited by vgersh99; 05-27-2009 at 02:01 PM..
Reason: spelling
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi All,
I have two files file1 and file2(lookup file).I need to map more than one keyfields of file1 with file2.how can we achieve it using awk.
file1(max 2.2 million records)
--------------------------
680720|680721|077
680720|680721|978
680721|680722|090
file2(no idea about the... (1 Reply)
Discussion started by: jerome Sukumar
1 Replies
2. UNIX for Advanced & Expert Users
Write a quick shell snippet to find all of the IPV4 IP addresses
in any and all of the files under /var/lib/output/*, ignoring
whatever else may be in those files. Perform a reverse lookup on
each, and format the output neatly, like "IP=192.168.0.1,
... (0 Replies)
Discussion started by: choco4202002
0 Replies
3. UNIX for Dummies Questions & Answers
foo.txt
FAMID IID AFF SEX Group AgeCat Dis1 Dis2 Dis3 Dis4 Dis5 Dis6 Dis6
AMD0001 Mayo_49542 1 2 AMD 8 1 1 1 1 1 1 1
AMD0002 Mayo_49606 1 1 AMD 3 1 1 1 1 ... (7 Replies)
Discussion started by: genehunter
7 Replies
4. UNIX for Dummies Questions & Answers
I have the below 2 files:
1) Third field from file1.txt should be compared to the first field of lookup.txt.
2) If match found then third field, file1.txt should be substituted with the second field from lookup.txt.
3)Else just print the line from file1.txt.
File1.txt:... (4 Replies)
Discussion started by: venalla_shine
4 Replies
5. Shell Programming and Scripting
have written a combined sed+awk to perform a lookup operation which works but looking to enhance it.
looking to match a record using any of the comma separated values + return selected fields from the record - including the field header. so:
cat foo
make,model,engine,trim,value... (6 Replies)
Discussion started by: jack.bauer
6 Replies
6. Shell Programming and Scripting
The below awk uses $3 and $4 in search as the min and max, then takes each $2 value in lookup and compares it. If the value in lookupfalls within the range in searchthen it prints the entire line in lookup/ICODE]. What I can't seem to figure out is how to print the matching $5 from search on that... (4 Replies)
Discussion started by: cmccabe
4 Replies
7. Shell Programming and Scripting
In the below, I am trying to lookup $1 and $2 from file1, in a range search using $1 $2 $3 of file2. If the search key from file1 is found in file2, then the word low is printed in the last field of that line in the updated file1. Only the last section of file1 needs to be searched, but I am not... (6 Replies)
Discussion started by: cmccabe
6 Replies
8. Shell Programming and Scripting
I am trying to update the below awk, kindly provided by @RavinderSingh13, to update each line of file1 with either Low or No Low based on matching $2 of file1 to a range in $2 and $3 of file2. If the $2 value in file1 matches the range in file2 then that line is Low, otherwise it is No Low in the... (3 Replies)
Discussion started by: cmccabe
3 Replies
9. Shell Programming and Scripting
The bash bash below extracts the oldest folder from a directory and stores it in filename
That result will match a line in bold in input. In the matching line there is an_xxx digit in italics that
(once the leading zero is removed) will match a line in link. That is the lint to print in output.... (2 Replies)
Discussion started by: cmccabe
2 Replies
10. Shell Programming and Scripting
I use conditional operators alot in AWK to print rows from large text files based on values in a certain column. For example:
awk -F '\t' '{ if ($1 == "A" || $1 == "C" ) print $0}' OFS="\t" file1.txt > file2.txt
In this case every row is printed from file1 to file2 for which the column 1... (5 Replies)
Discussion started by: Geneanalyst
5 Replies
LEARN ABOUT DEBIAN
prima::inifile
Prima::IniFile(3) User Contributed Perl Documentation Prima::IniFile(3)
NAME
Prima::IniFile - support of Windows-like initialization files
DESCRIPTION
The module contains a class, that provides mapping of text initialization file to a two-level hash structure. The first level is called
sections, which groups the second level hashes, called items. Sections must have unique keys. The items hashes values are arrays of text
strings. The methods, operated on these arrays are get_values, set_values, add_values and replace_values.
SYNOPSIS
use Prima::IniFile;
my $ini = create Prima::IniFile;
my $ini = create Prima::IniFile FILENAME;
my $ini = create Prima::IniFile FILENAME,
default => HASHREF_OR_ARRAYREF;
my $ini = create Prima::IniFile file => FILENAME,
default => HASHREF_OR_ARRAYREF;
my @sections = $ini->sections;
my @items = $ini->items(SECTION);
my @items = $ini->items(SECTION, 1);
my @items = $ini->items(SECTION, all => 1);
my $value = $ini-> get_values(SECTION, ITEM);
my @vals = $ini-> get_values(SECTION, ITEM);
my $nvals = $ini-> nvalues(SECTION, ITEM);
$ini-> set_values(SECTION, ITEM, LIST);
$ini-> add_values(SECTION, ITEM, LIST);
$ini-> replace_values(SECTION, ITEM, LIST);
$ini-> write;
$ini-> clean;
$ini-> read( FILENAME);
$ini-> read( FILENAME, default => HASHREF_OR_ARRAYREF);
my $sec = $ini->section(SECTION);
$sec->{ITEM} = VALUE;
my $val = $sec->{ITEM};
delete $sec->{ITEM};
my %everything = %$sec;
%$sec = ();
for ( keys %$sec) { ... }
while ( my ($k,$v) = each %$sec) { ... }
METHODS
add_values SECTION, ITEM, @LIST
Adds LIST of string values to the ITEM in SECTION.
clean
Cleans all internal data in the object, including the name of the file.
create PROFILE
Creates an instance of the class. The PROFILE is treated partly as an array, partly as a hash. If PROFILE consists of a single item,
the item is treated as a filename. Otherwise, PROFILE is treated as a hash, where the following keys are allowed:
file FILENAME
Selects name of file.
default %VALUES
Selects the initial values for the file, where VALUES is a two-level hash of sections and items. It is passed to read, where it is
merged with the file data.
get_values SECTION, ITEM
Returns array of values for ITEM in SECTION. If called in scalar context, and there is more than one value, the first value in list is
returned.
items SECTION [ HINTS ]
Returns items in SECTION. HINTS parameters is used to tell if a multiple-valued item must be returned as several items of the same
name; HINTS can be supplied in the following forms:
items( $section, 1 ) items( $section, all => 1);
new PROFILE
Same as create.
nvalues SECTION, ITEM
Returns number of values in ITEM in SECTION.
read FILENAME, %PROFILE
Flushes the old content and opens new file. FILENAME is a text string, PROFILE is a two-level hash of default values for the new file.
PROFILE is merged with the data from file, and the latter keep the precedence. Does not return any success values but, warns if any
error is occurred.
replace_values SECTION, ITEM, @VALUES
Removes all values form ITEM in SECTION and assigns it to the new list of VALUES.
section SECTION
Returns a tied hash for SECTION. All its read and write operations are reflected in the caller object, which allows the following
syntax:
my $section = $inifile-> section( 'Sample section');
$section-> {Item1} = 'Value1';
which is identical to
$inifile-> set_items( 'Sample section', 'Item1', 'Value1');
sections
Returns array of section names.
set_values SECTION, ITEM, @VALUES
Assigns VALUES to ITEM in SECTION. If number of new values are equal or greater than the number of the old, the method is same as
replace_values. Otherwise, the values with indices higher than the number of new values are not touched.
write
Rewrites the file with the object content. The object keeps an internal modification flag under name "{changed}"; in case it is
"undef", no actual write is performed.
AUTHORS
Anton Berezin, <tobez@plab.ku.dk>
Dmitry Karasik <dmitry@karasik.eu.org>
perl v5.14.2 2009-02-24 Prima::IniFile(3)