Sponsored Content
Top Forums Shell Programming and Scripting Compare columns of 2 files based on condition defined in a different file Post 302471569 by newtoawk on Saturday 13th of November 2010 10:26:10 PM
Old 11-13-2010
thanks Pravin, it worked. Can I pass the field delimiter as a variable.B'cas I need to read the output format from a file.
for ex: instead of nawk -F'|' -- can I do it something like this
output_format=| or output_format=\t
nawk -F'$output_format' ... does this work, or is there anyother way to do it.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

compare two columns of different files and print the matching second file..

Hi, I have two tab separated files; file1: S.No ddi fi cu o/l t+ t- 1 0.5 0.6 o 0.1 0.2 2 0.2 0.3 l 0.3 0.4 3 0.5 0.8 l 0.1 0.6 ... (5 Replies)
Discussion started by: vasanth.vadalur
5 Replies

2. Shell Programming and Scripting

How to compare 2 files & get only few columns based on a condition related to both files?

Hiiiii friends I have 2 files which contains huge data & few lines of it are as shown below File1: b.dat(which has 21 columns) SSR 1976 8 12 13 10 44.00 39.0700 70.7800 7.0 0 0.00 0 2.78 0.00 0.00 0 0.00 2.78 0 NULL ISC 1976 8 12 22 32 37.39 36.2942 70.7338... (6 Replies)
Discussion started by: reva
6 Replies

3. Shell Programming and Scripting

compare 2 files based on columns

Hi Experts, Is there a way to compare 2 files by columns and print matching cases. I have 2 files as below, I want cases where col1 and col2 in f1 matches col1 and col2 in f2 to be printed as output. The separator is space. I want the output to have col1 col2 col 3 from both files printed... (7 Replies)
Discussion started by: novice_man
7 Replies

4. Shell Programming and Scripting

compare 2 files and extract the data which is not present in other file with condition

I have 2 files whose data's are as follows : fileA 00 lieferungen 00 attractiop 01 done 02 forness 03 rasp 04 alwaysisng 04 funny 05 done1 fileB alwayssng dkhf fdgdfg dfgdg sdjkgkdfjg funny rasp (7 Replies)
Discussion started by: rajniman
7 Replies

5. Shell Programming and Scripting

compare 2 files and return unique lines in each file (based on condition)

hi my problem is little complicated one. i have 2 files which appear like this file 1 abbsss:aa:22:34:as akl abc 1234 mkilll:as:ss:23:qs asc abc 0987 mlopii:cd:wq:24:as asd abc 7866 file2 lkoaa:as:24:32:sa alk abc 3245 lkmo:as:34:43:qs qsa abc 0987 kloia:ds:45:56:sa acq abc 7805 i... (5 Replies)
Discussion started by: anurupa777
5 Replies

6. Shell Programming and Scripting

Compare files in a folder based on another file

I have a file named file.txt that looks as follows //class1.txt 45 234 67 89 90 //class2.txt 456 34 78 89 120 class1 and class2.txt are the names of files in a folder named folder1. The content of class1.txt file in folder1 67 9 89 5 234 9The content of class2.txt file in... (1 Reply)
Discussion started by: jaff rufus
1 Replies

7. Shell Programming and Scripting

Extracting rows and columns in a matrix based on condition

Hi I have a matrix with n rows and m columns like below example. i want to extract all the pairs with values <200. Input A B C D A 100 206 51 300 B 206 100 72 48 C 351 22 100 198 D 13 989 150 100 Output format A,A:200 A,C:51 B,B:100... (2 Replies)
Discussion started by: anurupa777
2 Replies

8. Shell Programming and Scripting

Convert rows to columns based on condition

I have a file some thing like this: GN Name=YWHAB; RC TISSUE=Keratinocyte; RC TISSUE=Thymus; CC -!- FUNCTION: Adapter protein implicated in the regulation of a large CC spectrum of both general and specialized signaling pathways GN Name=YWHAE; RC TISSUE=Liver; RC ... (13 Replies)
Discussion started by: raj_k
13 Replies

9. Shell Programming and Scripting

[Solved] awk compare two different columns of two files and print all from both file

Hi, I want to compare two columns from file1 with another two column of file2 and print matched and unmatched column like this File1 1 rs1 abc 3 rs4 xyz 1 rs3 stu File2 1 kkk rs1 AA 10 1 aaa rs2 DD 20 1 ccc ... (2 Replies)
Discussion started by: justinjj
2 Replies

10. Shell Programming and Scripting

I have this list of files . Now I will have to pick the latest file based on some condition

3679 Jul 21 23:59 belk_rpo_error_**po9324892**_07212014.log 0 Jul 22 23:59 belk_rpo_error_**po9324892**_07222014.log 3679 Jul 23 23:59 belk_rpo_error_**po9324892**_07232014.log 22 Jul 22 06:30 belk_rpo_error_**po9324267**_07012014.log 0 Jul 20 05:50... (5 Replies)
Discussion started by: LoneRanger
5 Replies
Data::Hexdumper(3pm)					User Contributed Perl Documentation				      Data::Hexdumper(3pm)

NAME
Data::Hexdumper - Make binary data human-readable SYNOPSIS
use Data::Hexdumper qw(hexdump); print hexdump( data => $data, # what to dump # NB number_format is deprecated number_format => 'S', # display as unsigned 'shorts' start_position => 100, # start at this offset ... end_position => 148 # ... and end at this offset ); print hexdump( "abcdefg", { output_format => '%4a : %C %S< %L> : %d' } ); DESCRIPTION
"Data::Hexdumper" provides a simple way to format arbitrary binary data into a nice human-readable format, somewhat similar to the Unix 'hexdump' utility. It gives the programmer a considerable degree of flexibility in how the data is formatted, with sensible defaults. It is envisaged that it will primarily be of use for those wrestling alligators in the swamp of binary file formats, which is why it was written in the first place. SUBROUTINES
The following subroutines are exported by default, although this is deprecated and will be removed in some future version. Please pretend that you need to ask the module to export them to you. If you do assume that the module will always export them, then you may also assume that your code will break at some point after 1 Aug 2012. hexdump Does everything. Takes a hash of parameters, one of which is mandatory, the rest having sensible defaults if not specified. Available parameters are: data A scalar containing the binary data we're interested in. This is mandatory. start_position An integer telling us where in "data" to start dumping. Defaults to the beginning of "data". end_position An integer telling us where in "data" to stop dumping. Defaults to the end of "data". number_format This is deprecated. See 'INCOMPATIBLE CHANGES' below. If you use this your data will be padded with NULLs to be an integer multiple of 16 bytes. You can expect number_format to be removed at some point in 2014 or later. A string specifying how to format the data. It can be any of the following, which you will notice have the same meanings as they do to perl's "pack" function: C - unsigned char S - unsigned 16-bit, native endianness v or S< - unsigned 16-bit, little-endian n or S> - unsigned 16-bit, big-endian L - unsigned 32-bit, native endianness V or L< - unsigned 32-bit, little-endian N or L> - unsigned 32-bit, big-endian Q - unsigned 64-bit, native endianness Q< - unsigned 64-bit, little-endian Q> - unsigned 64-bit, big-endian Note that 64-bit formats are *always* available, even if your perl is only 32-bit. Similarly, using < and > on the S and L formats always works, even if you're using a pre 5.10.0 perl. That's because this code doesn't use "pack()". output_format This is an alternative and much more flexible (but more complex) method of specifying the output format. Instead of specifying a single format for all your output, you can specify formats like: %4a : %C %S %L> %Q : %d which will, on each line, display first the address (consisting of '0x' and 4 hexadecimal digits, zero-padded if necessary), then a space, then a colon, then a single byte of data, then a space, then an unsigned 16-bit value in native endianness, then a space, then an unsigned 32-bit big-endian value, ... then a colon, a space, then the characters representing your 15 byte record. You can use exactly the same characters and character sequences as are specified above for number_format, plus 'a' for the address, and 'd' for the data. To output a literal % character, use %% as is normal with formats - see sprintf for details. To output a literal < or > character where it may be confused with any of the {S,L,Q}{<,>} sequences, use %< or %>. So, for example, to output a 16-bit value in native endianness followed by <, use %S%<. %a takes an optional base-ten number between the % and the a signifying the number of hexadecimal digits. This defaults to 4. %{C,S,L,Q} also take an optional base-ten number between the % and the letter, signifying the number of repeats. These will be separated by spaces in the output. So '%4C' is equivalent to '%C %C %C %C'. Anything else will get printed literally. This format will be repeated for as many lines as necessary. If the amount of data isn't enough to completely fill the last line, it will be padded with NULL bytes. To specify both number_format and output_format is a fatal error. If neither are given, output_format defaults to: ' %4a : %16C : %d' which is equivalent to the old-style: number_format => 'C' suppress_warnings Make this true if you want to suppress any warnings - such as that your data may have been padded with NULLs if it didn't exactly fit into an integer number of words, or if you do something that is deprecated. space_as_space Make this true if you want spaces (ASCII character 0x20) to be printed as spaces Otherwise, spaces will be printed as full stops / periods (ASCII 0x2E). Alternatively, you can supply the parameters as a scalar chunk of data followed by an optional hashref of the other options: $results = hexdump($string); $results = hexdump( $string, { start_position => 100, end_position => 148 } ); SEE ALSO
Data::Dumper Data::HexDump if your needs are simple perldoc -f unpack perldoc -f pack INCOMPATIBLE CHANGES
'number_format' is now implemented in terms of 'output_format'. Your data will be padded to a multiple of 16 bytes. Previously-silent code may now emit warnings. The mappings are: 'C' => ' %4a : %C %C %C %C %C %C %C %C %C %C %C %C %C %C %C %C : %d' 'S' => ' %4a : %S %S %S %S %S %S %S %S : %d' 'S<' => ' %4a : %S< %S< %S< %S< %S< %S< %S< %S< : %d' 'S>' => ' %4a : %S> %S> %S> %S> %S> %S> %S> %S> : %d' 'L' => ' %4a : %L %L %L %L : %d' 'L<' => ' %4a : %L< %L< %L< %L< : %d' 'L>' => ' %4a : %L> %L> %L> %L> : %d' 'Q' => ' %4a : %Q %Q : %d' 'Q<' => ' %4a : %Q< %Q< : %d' 'Q>' => ' %4a : %Q> %Q> : %d' and of course: 'V' => 'L<' 'N' => 'L>' 'v' => 'S<' 'n' => 'S>' BUGS
/LIMITATIONS Behaviour of %a is not defined if your file is too big. Behaviour of %NNa is not defined if NN is too big for your sprintf implementation to handle 0x%0${NN}X. FEEDBACK
I welcome constructive criticism and bug reports. Please report bugs either by email or via RT: http://rt.cpan.org/Public/Dist/Display.html?Name=Data-Hexdumper <http://rt.cpan.org/Public/Dist/Display.html?Name=Data-Hexdumper> The best bug reports contain a test file that fails with the current code, and will pass once it has been fixed. The code repository is on Github: git://github.com/DrHyde/perl-modules-Data-Hexdumper.git <git://github.com/DrHyde/perl-modules-Data-Hexdumper.git> AUTHOR, COPYRIGHT and LICENCE Copyright 2001 - 2012 David Cantrell <david@cantrell.org.uk> This software is free-as-in-speech software, and may be used, distributed, and modified under the terms of either the GNU General Public Licence version 2 or the Artistic Licence. It's up to you which one you use. The full text of the licences can be found in the files GPL2.txt and ARTISTIC.txt, respectively. CONSPIRACY
This module is also free-as-in-mason software. THANKS TO ... MHX, for reporting a bug when dumping a single byte of data Stefan Siegl, for reporting a bug when dumping an ASCII 0 Steffen Winkler, for inspiring me to use proper output formats perl v5.14.2 2012-05-29 Data::Hexdumper(3pm)
All times are GMT -4. The time now is 09:51 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy